Search code examples
netsuitesaved-searches

Finding role and script deployment relations im Netsuite


Is it possible to easily see which roles have access to which script deployments?

I tried making a script deployments saved search as well as a role saved search but could not really find out how to extract this information.

Does anyone know?


Solution

  • I cannot see a way to complete this in the UI/via saved search. You can complete this via suitescript however by following this sort of layout. You can schedule the script to run periodically, or just run in the browser console to get the data you want. You can also add code to create an excel file to easily digest the information...

    Layout in SS2.0

    //gather all applicable role ids
    var Roles = [];
    
    //gather all applicable script deployment ids
    var ScriptDep = [];
    
    //for each script deployment id get the "Roles" from the "Audience" tab in the UI
    for (var i=0; i<ScriptDep.length; i++){
      var script = record.load({
        type: 'scriptdeployment',
        id: ScriptDep[i]
      });
      var scriptAudienceField = script.getField({
        fieldId: 'audslctrole'
      });
      var scriptAudience = scriptAudienceField.getSelectOptions({
        filter : '*',
        operator : 'contains'
      });
      var RoleID = ; //role ID you care about, maybe loop through all roles with Roles[j]
      var test = scriptAudience.includes(RoleID); //returns true or false this deployment is deployed to this role
      
    }
    

    Suite Answer 86327 gives the dollowing SS1.0 sample code

    var search = nlapiLoadSearch('scriptdeployment', 147); //load search of all script deployments
    var resultSet = search.runSearch();
    resultSet.forEachResult(function(searchResult){ //for each script deployment returned by the search, get the id
      var record = nlapiLoadRecord('scriptdeployment', searchResult.id); //load the script deployemnt
      var arrayOfRoles = record.getFieldValues('audslctrole'); //get the values of the "Roles" from the "Audience" tab in the UI
      if(arrayOfRoles == '18'){ //change based on the internal ID of the role
        console.log(searchResult.id);
      };
      return true;       
    });