Prepopulate Reference Field
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-22-2016 10:14 AM
Hello All --
I know this is possible but I'm drawing a complete blank. I'm trying to establish a reference field link between two tables so that data from one
table can be displayed on the other. I'm trying to configure it so that the reference field is populating on its own without needing to manually
type anything in.
Here's my set up
Number is my autonumbered record. Approval History is a reference to a second table where I store the Number plus the fields I have showing under the green arrow.
The structure of that table is like this:
I am trying to populate the Approval History field to prepopulate so the field information shows on its own.
I have tried both a client script and business rule to populate the field with no luck. In both cases, I used code like this:
var id = current.sys_id;
current.u_approval_history = id;
current.update();
To no avail.
I would appreciate other ideas on how to do this.
Thanks!
Chris
- Labels:
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-22-2016 10:54 AM
I think you're just missing the .getDisplayValue() .
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-22-2016 10:59 AM
Alexander -
I'm not sure where the getDisplayValue would go in this case - could you be more specific?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-22-2016 11:02 AM
Sorry, I read the tail end of your message and might not even be addressing the main issue. I actually just tested it out with a client script and I didn't need to add getDisplayValue()
I made a client script that reads the user in one reference field and grabs their location and enters it in the 'district' field, which is a reference field to our cmn_location table.
function onChange(control, oldValue, newValue, isLoading) {
if(isLoading){ return; }
var userRecord = g_form.getReference('requested_for');
g_form.setValue('district', userRecord.location);
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-22-2016 11:11 AM
I tried the following in an onLoad client script and I still get nothing:
function onLoad() {
var approvalHist = g_form.getReference('u_approval_history');
g_form.setValue('u_approval_history', approvalHist.u_request_id);
}