Advertisement
Guest User

Untitled

a guest
Jun 18th, 2018
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. var i = 0;
  2. var line = new GlideRecord('u_sr_mapping_line');
  3. line.addQuery('u_type', 'includeMap');
  4. line.addQuery('u_value', 'MMSA_Group_Configuration_mapping_v1');
  5. line.queryNoDomain();
  6. while(line.next()){
  7.     var order = parseInt(line.u_order, 10);
  8.     var mappingBlock = line.u_mapping_block.sys_id.toString();
  9.    
  10.     gs.print('Mapping block for group config found for: ' + line.u_mapping_block.u_name.toString());
  11.  
  12.     var lineExists = checkIfAlreadyExists(mappingBlock);
  13.  
  14.     if(!lineExists){
  15.         var newOrder = (order + 1).toString();
  16.         var newLine = new GlideRecord('u_sr_mapping_line');
  17.         newLine.initialize();
  18.         newLine.u_mapping_block = mappingBlock;
  19.         newLine.u_output_parm = 'includeRITMDetails';
  20.         newLine.u_type =  'includeMap';
  21.         newLine.u_value = 'MMSA_includeRITMDetails';
  22.         newLine.u_order = newOrder;
  23.         newLine.u_active = true;
  24.         newLine.insert();
  25.  
  26.         gs.print('Created new mapping line for: ' + line.u_mapping_block.u_name + ' with order: ' + newOrder + '\n');
  27.  
  28.     }
  29.     else{
  30.         gs.print('This mapping line already exists for mapping block: ' + line.u_mapping_block.u_name.toString() + '\n');
  31.     }
  32.  
  33.     i++;
  34. }
  35.  
  36. gs.print('\n\n' + i + ' Transactions affected by script')
  37.  
  38.  
  39. function checkIfAlreadyExists(mappingBlock){
  40.     var gr = new GlideRecord('u_sr_mapping_line');
  41.     gr.addQuery('u_type', 'includeMap');
  42.     gr.addQuery('u_value', 'MMSA_includeRITMDetails');
  43.     gr.addQuery('u_mapping_block', mappingBlock);
  44.     gr.query();
  45.     if(gr.next()){
  46.         return true;
  47.     }
  48.     else{
  49.         return false;
  50.     }
  51. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement