Setting a default value in a variable
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-21-2017 01:31 PM
I am very new to scripting and need some help on the following
I am creating a Catalog item which has a variable name called Application which is a reference field to the Application table . I want the field owned by for that application on the application table to populate the variable Owned By on the catalog item.
Its probably easy for all you awesome developers so any help would be very much appreciated .
Thanks JD
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-21-2017 01:51 PM
Just to verify - you want that populated when the Application variable is changed? If so, give this a shot:
OnChange client script:
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading || newValue === '') {
return;
}
var getob = g_form.getReference('application_variable_name', function(ob) {
g_form.setValue('owned_by_variable_name', ob.owned_by);
});
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-21-2017 01:51 PM
Try this catalog client script.
Type: onChange
Field: Application
Script:
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
var app = g_form.getReference('application_variable_name',callBack);
}
function callBack(app){
g_form.setValue('owned_by_variable',app.owned_by); // owned_by here is the backend name of Owned by field
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-21-2017 03:21 PM
So this is what I have for the script
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
var app = g_form.getReference('application',callBack);
}
function callBack(app){
g_form.setValue('owner',app.owned_by);
}
So the variable Owner gets populated but it is a list of numbers like the sys_id not the Owner Name
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-21-2017 03:37 PM
Its the sys_id of the user record in the sys_user table , the Owned By field in the Application table is a reference field to the user table