Set Value of a field on the record not available on form once the onload client script runs
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-24-2023 01:26 AM
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);
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-24-2023 01:58 AM
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-24-2023 02:13 AM
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-24-2023 04:19 AM
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-24-2023 02:21 AM
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();
}
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-24-2023 02:52 AM
Thanks Amol
Thanks
Abi