- 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,634 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-14-2017 02:47 AM
Hi Kiran,
You can access dot-walk fields on a form with the g_form API, without the need of using getReference.
As an example, on the Requested Item [sc_req_item] table there is a derived (or dot-walked) field called Requested for. To get the value you can use:
g_form.getValue("request.requested_for");
"request" is the name of the Request field on the RITM form, and "requested_for" is the field derived from the "request" record.
So the logic you want to work with would be along the lines of:
var requestedFor = g_form.getValue("request.requested_for");
var assignedTo = g_form.getValue("assigned_to");
if (requestedFor == assignedTo) {
// Do something...
}
This would be useful if the values are expected to change on the form. If the field values are static then you can still use this script, or just follow Christopher's steps and get the dot-walk value in the g_scratchpad variable.
Hope this helps guide your next steps
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-14-2017 03:32 AM
tried this not working
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-14-2017 03:43 AM
Thanks Corey
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-14-2017 02:49 AM
Hey Kiran,
Haven't gone through the whole thread, but to get the value of a reference field on client side you can directly use the code below
g_form.DisplayBox('new_hire_position').value
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-21-2018 01:43 PM
I tried this in Kingston, but am getting "not a function". Am I using it wrong?
Here's the code in my onLoad script:
var userID = g_form.getValue("submitter");
console.log('the submitter ref: ' + userID);
var xyz = g_form.DisplayBox('submitter').value;
console.log('###: ' + xyz);
g_form.setValue('attention', xyz);
Here's what comes out to the Console:
the submitter ref: 64fc34064fe3a60072e758211310c743
(g_env) [SCRIPT:EXEC] Error while running Client Script "Set Date and Attention on Order": TypeError: g_form.DisplayBox is not a function