- 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,640 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:24 PM
i tried this not working

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-13-2017 03:02 PM
You question is like a tongue twisters 😉
Please check if this helps.
function onChange(control, oldValue, newValue, isLoading) {
var assign = g_form.getReference('<reference field name of Requester(userfield of Request table) on RequestTask>', doAlert);
}
function doAlert(assign) {
if (assign.sys_id == g_form.getValue('field name of AssignedTo on RequestTask'))
alert('RequestedFor and AssignedTo can\'t be same');
return false;
}

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-13-2017 12:24 PM
Since the Requested for field is on the Request [sc_request] table, it may be best to capture that in a g_scratchpad object and check against the Assigned to on the Catalog Task [sc_task] record. In order to set the g_scratchpad object, you need to create an onDisplay Business Rule. Then you will change your script to check accordingly.
1. Create a Business Rule to capture the Requested for Value:
Name: Set g_scratchpad for sc_task
Table: Catalog Task [sc_task]
When: display
Script:
(function executeRule(current, previous /*null when async*/) {
g_scratchpad.requested_for = current.request_item.request.requested_for;
})(current, previous);
2. Change your onSubmit Client Script:
function onSubmit() {
var assignedTo = g_form.getValue('assigned_to');
if (g_scratchpad.requested_for == assignedTo) {
alert('Requested for and Assigned to can\'t be same');
return false;
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-13-2017 01:59 PM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-13-2017 02:06 PM
I would avoid doing getReference() calls without a callback function associated with them. Since it appears that there is a hidden field called request, I changed my Business rule accordingly:
(function executeRule(current, previous /*null when async*/) {
g_scratchpad.requested_for = current.request.requested_for;
})(current, previous);