Set Value of a field on the record not available on form once the onload client script runs

Nishant16
Tera Expert

Hi All,

 

I have a requirement to run Client Script based on a condition that the record field "Is Present" is true then run the client script. 

Field "Is Present" is not available on form, so i pass this value to Client script using scratchpad, now once the client script runs i need to set this Field value to false, how can i do this.

if(g_scratchpad.IsPresent)){
var rstate = g_form.getValue("state");
if(rstate.includes("closed")) {
g_form.setReadOnly("state", true);
}
}

9 REPLIES 9

hi Anurag,

 

Basically i am creating a new record from a integration and when that record creates i want to open related Case for the first time and thats why i am using field "u_is_present" on form as true and using client script to open the related record.
Now next time when i open it should not open the related record and thats why i want to set "u_is_present" to false.

Why not add the field u_is_present on the form and keep it hidden always then? 

You can update the field to flase if it is true and thats it.

-Anurag

Hi Anurag,

 

We do not have to show it on the form, need to keep it hidden since this is set from integration. Is there a way to set this field after my client script runs.

IamAmolB
Tera Guru

Hi Abhigyan,

 

Your code what you have written is correct just few modification required

if(g_scratchpad.IsPresent)){
var rstate = g_form.getValue("state");
if(rstate.includes("closed")) {
g_form.setReadOnly("state", true);

 

var ga = new GlideAjax('clientUtilsetIsPresent');

ga.addParam('sysparm_name', 'setIsPresent');

ga.addParam('sysparm_sysID, g_form.getUniqueValue());

ga.addParam('sysparm_bull, false);

ga.getXMLWait();

}

 

Server Side (Script Include):
var clientUtilsetIsPresent= Class.create();

clientUtilsetIsPresent.prototype = Object.extendsObject(AbstractAjaxProcessor, {

setIsPresent: function () {

var isParentValue = this.getParameter('sysparm_bull');

var sysID = this.getParameter('sysparm_sysID');

var inc = new GlideRecord('YourTableName');

inc.addQuery('sys_id',sysID);

inc.query();

 

if(inc.next()){

inc.IsParent = isParentValue;

inc.update();

}

 

}

}

Thanks Amol

If my answer solved your issue, please mark my answer as Correct & hit like Helpful

Thanks
Abi