Skip to main content

I am trying to trigger a script when a the end date is changed on the contracts screen. I tested the script itself and it works fine, but I cant get it to trigger when I want it to. The field I need to update is a custom field called Months Remaining and is linked to contracts.user_def5.

 

I linked the script to End Date.

 

Here is the client script:

var contractID = getControlValue('contract', 'contract_id');
var contractLength = getDBValue('1', contractID);
setControlValue('contract', 'user_def5', contractLength);
alert("done");

 

And the sql script it calls:

SELECT DATEDIFF(M,GETDATE(),CONTRACT.END_DT) FROM CONTRACT WHERE CONTRACT_ID = '{0}'

Are there other ways of triggering this?

Hi @Fluffy ,

Have you tried adding the script as custom code on the click event in the save button?

 


Ok. It works thanks!


Is it possible to trigger it when a field changes? Perhaps only update the text on another field without saving to the databasis? 


@Fluffy ,

I doubt whether the textchanged event would work for this particular scenario as it does not behave as a standard text field (since it’s a dttm field). Otherwise it should work in the normal way. Have you tried this on the webclient with AddEditOpened screen event? But this will only work in the web client. Another option would be to set the script with an initial focus then triggering it with gotfocus event but I wonder whether that would work out well as per the requirement. Having the script on the save button captures the script on the click event but yes, that concern is there again, you need to click on the save button. 


Reply