record producer script to utilise script include

mskelly
Giga Contributor

Hi Folks,

I have a large script in a record producer which works but now has grown too big for ServiceNow to parse.

So my idea is to utilise Script includes to move the majority of code to a server side "Script Includes"

Alas my skills do not stretch to this so please could someone give me a hand.

The record producer has lots of checkbox variables and based on what the user selects the RP script need to call out to the Script Include and write the result back to the RP script

So an example of the RP script

  if (producer.ItalyBentel_COEINV =='true' || producer.ItalyBentel_IBMINV =='true'){

  current.description= current.description + '\r\n'+'SGTFSEU_APP_191_WEB';

  current.description= current.description + '\r\n'+'SGTFSEU_APP_AGENZIA_DOGANE';

  current.description= current.description + '\r\n'+'SGTFSEU_APP_ALD';

  current.description= current.description + '\r\n'+'SGTFSEU_APP_AMEX';

  }

So I need move this into Script Includes any ideas?

1 ACCEPTED SOLUTION

mskelly
Giga Contributor

OK I have found the answer



The Script include does this



var updateRP3 = Class.create();


updateRP3.prototype = {


      initialize: function() {},




updatebentel :function(){



  if (producer.ItalyBentel_COEINV =='true' || producer.ItalyBentel_IBMINV =='true'){


  current.description= current.description + '\r\n'+'SGTFSEU_APP_191_WEB';


  current.description= current.description + '\r\n'+'SGTFSEU_APP_AGENZIA_DOGANE';


  current.description= current.description + '\r\n'+'SGTFSEU_APP_ALD';


  current.description= current.description + '\r\n'+'SGTFSEU_APP_AMEX';


  current.insert();


  }




},




      type: 'updateRP3'};




In the RP I have this



var rpbentel =new updateRP3();


rpbentel.updatebentel();




and this works a treat thanks you for your responses                  



Mark


View solution in original post

5 REPLIES 5

mskelly
Giga Contributor

OK I have found the answer



The Script include does this



var updateRP3 = Class.create();


updateRP3.prototype = {


      initialize: function() {},




updatebentel :function(){



  if (producer.ItalyBentel_COEINV =='true' || producer.ItalyBentel_IBMINV =='true'){


  current.description= current.description + '\r\n'+'SGTFSEU_APP_191_WEB';


  current.description= current.description + '\r\n'+'SGTFSEU_APP_AGENZIA_DOGANE';


  current.description= current.description + '\r\n'+'SGTFSEU_APP_ALD';


  current.description= current.description + '\r\n'+'SGTFSEU_APP_AMEX';


  current.insert();


  }




},




      type: 'updateRP3'};




In the RP I have this



var rpbentel =new updateRP3();


rpbentel.updatebentel();




and this works a treat thanks you for your responses                  



Mark