- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-13-2017 12:04 PM
If I create a Request, it will create a Request and RequestItem as child/under of Request and RequestTask created under RequestItem.
here Requester(userfield) and RequestID are fields of Request and is shown on RequestTask form as reference fields.
RequestTask has AssignedTo(Userfield) field.
Now I am writing a client script(on RequestTask) to validate AssignedTo(UserField of RequestTask) can't be same as Requester(userfield which is Request field) which is a reference field on RequestTask
Client Script :
function onSubmit() {
//Type appropriate comment here, and begin script below
if(g_form.getValue('requested_for')==g_form.getValue('assigned_to')){ // alert(g_form.getValue('requested_for')); getting blank , how can i get 'requested_for' field value from RequestTask form
alert('RequestedFor and AssignedTo can\'t be same');
return false;
}else
{
return;
}
}
Regards,
Kiran Pedduri
Solved! Go to Solution.
- Labels:
-
Scripting and Coding
- 40,628 Views

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-10-2018 06:38 AM
g_form.getDisplayBox('fieldname').value
Mark correct or helpful if it helps you
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-13-2017 12:14 PM
Is this script being ran on a sc_task? If so I believe that requested for is not a field available on this table. If you want to get the requested for value you must dot walk to its parent request (request).
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-13-2017 12:27 PM
Is this script being ran on a sc_task? Answer: Yes
Request table Name = sc_request
RequestItem table Name = sc_req_item
RequestTask table Name = sc_task
please let me know the statement. as I have RequestID(REQUEST field) which is reference field on RequestTask form, can I get the Request record object and fetch Requestor field value?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-13-2017 06:58 PM
try the following
function onSubmit() {
var assignedto = g_form.getDisplayValue('assigned_to');
var requestedfor = g_foem.getDisplayValue('requested_for');
if ( assignedto == requestedfor )
{
Alert('assignedto and requested for can't be same');
return;
}
}
Thanks
PS: hit correct/helpful...if it helps

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-13-2017 12:22 PM
you can use the getReference to glide the record of particular reference field, please find more details here: GlideForm (g form) - ServiceNow Wiki