# SaveAdvancedSearchColumns - Advanced Documentation ## When to Use Use this to store the result columns of a saved search you can edit: one you created, or a firm search when you hold the firm permission. To run a search without saving anything, use `ExecuteAdvancedSearch` instead. See the workflow at the top of `GetAdvancedSearchResults` documentation. ## Overview Replaces the whole saved column list of one search with the `SearchColumnInfo` list you pass, and returns the list as saved. Nothing is merged: send every column every time. Fetch the current columns with `GetAdvancedSearchColumns`, change them, and send them back. ## Permissions - The caller needs ManageAdvancedSearch. - A firm search (`IsFirmAdvancedSearch`) also needs ManageFirm. - A search that is not a firm search can only be edited by the person who created it. - A search that is a shortcut to another search cannot have its columns updated. Failures throw a `RadoloException` with a plain message. ## What Is Required - `AdvancedSearchID` must be 1 or greater: `Search columns must have an associated advanced search.` - Every column needs a `DisplayName`, a `Width` of at least 1, an `AggregateFunction`, a `Format`, and a non-empty `FieldList`. - Every `FieldList` entry needs `FieldName`, `FieldSource`, `DisplayName`, and `FieldType`. The last entry (the leaf) also needs `DataType` and must not have a `NextEntityName`. - A column must be unique: the same `DisplayName` and `FieldPath` used twice is rejected. - `SortDirection` must be `null`, `"Ascending"`, or `"Descending"`. Copy field entries from `GetAdvancedSearchFields` (`IsColumnField` true), and copy `Width`, `AggregateFunction`, and `Format` from a column returned by `GetAdvancedSearchColumns`. ## Sort Is Stored, Not Applied Only one column keeps a `SortDirection`: if several columns carry one, every column after the first has it cleared before saving. The value is stored with the column, but the SQL the API builds for results has no `ORDER BY`, so sort is not applied to the rows `GetAdvancedSearchResults`, `GetAdvancedSearchResultString`, or `ExecuteAdvancedSearch` return. Sort the rows in your script. ## Example ```javascript async () => { const columns = await SecureApi.GetAdvancedSearchColumns(advancedSearchId); // adjust DisplayName or Width in place, keep everything else as it arrived return await SecureApi.SaveAdvancedSearchColumns(advancedSearchId, columns); } ```