Call script include from record producer script field

JJG
Kilo Guru

Hello,

I have a lengthy script that i need to run that I would like to place inside of a script include rather than the record producer script field. I need to call the script include and have access to the record producer variables from the script include. Here is what I have so far, it is not working yet:

Record Producer:

var callScriptInclude = new updateContractChangeField().contractChanges();

 

Script Include:

var updateContractChangeField = Class.create();
updateContractChangeField.prototype = Object.extendsObject(global.AbstractAjaxProcessor, {
   
	contractChanges: function(producer, current) {
        var contractName = producer.contract_name;
        gs.info('Contract Name: ' + contractName);
    },


    type: 'updateContractChangeField'
});

 

As you can see, I am trying to pull the contract_name variable from the producer. This is not working, the logs do not reflect the gs.info()

1 ACCEPTED SOLUTION

Jim Coyne
Kilo Patron

Your "contractChanges" function has the parameters in its declaration, but you are not passing them in from the RP script.  Try:

var callScriptInclude = new updateContractChangeField().contractChanges(producer, current);

Or if you are just dealing with 1 piece of data, just pass it instead of the whole "producer" object.  Like:

var callScriptInclude = new updateContractChangeField().contractChanges(producer.contract_name.toString(), current);

View solution in original post

7 REPLIES 7

Jim Coyne
Kilo Patron

Your "contractChanges" function has the parameters in its declaration, but you are not passing them in from the RP script.  Try:

var callScriptInclude = new updateContractChangeField().contractChanges(producer, current);

Or if you are just dealing with 1 piece of data, just pass it instead of the whole "producer" object.  Like:

var callScriptInclude = new updateContractChangeField().contractChanges(producer.contract_name.toString(), current);

I tried the first one:

var callScriptInclude = new updateContractChangeField().contractChanges(producer, current);

 

the gs.info is showing the following: Contract Name: undefined

 

any idea on how to fix this?

SOLVED: I just left out the 'current' on the record producer and script include

var callScriptInclude = new updateContractChangeField().contractChanges(producer);