- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-31-2022 08:39 AM
Hello All,
I have a use case, where I have to check for condition if parent field is empty or not.
1) If parent field is not empty then I have to call my script include.
2) If parent field is empty, then do nothing.
I have to check these things as soon as form load, so I'm using onload client script, but it is not checking the empty for parent field empty everytime it goes for another condition. Can anyone help hea?
Note: Everytime it is going in else section.
function onLoad() {
var parentField = g_form.getValue('parent');
alert(parentField);
if( g_form.getValue('parent')== undefined){
alert("Empty");
}else{
alert("Glideajax");
var ga = new GlideAjax('x_kpm14_security_i.PopulateTaskType'); //Scriptinclude
ga.addParam('sysparm_name', 'getUserDetails'); //Method
ga.addParam('parentID',parentField); //Parameters
ga.getXMLAnswer(getResponse);
}
Solved! Go to Solution.
- Labels:
-
Scripting and Coding

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-31-2022 08:41 AM
Can you try
function onLoad() {
var parentField = g_form.getValue('parent');
alert(parentField);
if( g_form.getValue('parent') == ""){
alert("Empty");
}else{
alert("Glideajax");
var ga = new GlideAjax('x_kpm14_security_i.PopulateTaskType'); //Scriptinclude
ga.addParam('sysparm_name', 'getUserDetails'); //Method
ga.addParam('parentID',parentField); //Parameters
ga.getXMLAnswer(getResponse);
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-31-2022 08:59 AM
sorry for misunderstanding.
I copy pasted wrong one. Correct if condition below:
var parentField = g_form.getValue('parent');
if( parentField== ''){
alert("Empty");
}
It is not working

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-31-2022 09:47 AM
Sure No problem.
Glad its solved.
***Mark Correct or Helpful if it helps.***