- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-25-2018 08:15 AM
I want to set a default value based on the condition and I tried below script in the default filed of dictionary but it didn't work.
If type = group, set the responsibility to 'ABC'(sys_id=1233456667889) of new record only
Solved! Go to Solution.
- Labels:
-
Incident Management

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-25-2018 09:11 AM
function onLoad() {
if(g_form.isNewRecord())
{
var type = g_form.getValue('type');
var res = g_form.getValue('responsbility');
if(type == 'group' && res !='')
{
g_form.setValue('responsbility','<sys id that you want to set>');
}
}
}
Try now.. g_form.isNewRecord() will only allow this onload script to run for new record.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-25-2018 08:54 AM
Try this:
function onLoad() {
var type = g_form.getValue('type'); //Type should be the backend value for type field
var res = g_form.getValue('responsbility');
if(type == group && res !='')
{
g_form.setValue('responsbility','1233456667889'); //Responsibility should be backend value
}

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-25-2018 09:11 AM
function onLoad() {
if(g_form.isNewRecord())
{
var type = g_form.getValue('type');
var res = g_form.getValue('responsbility');
if(type == 'group' && res !='')
{
g_form.setValue('responsbility','<sys id that you want to set>');
}
}
}
Try now.. g_form.isNewRecord() will only allow this onload script to run for new record.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-26-2018 04:21 AM
Thanks it worked... instead of using type as 'group', I used type = 'sys_user_group'
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-25-2018 12:38 PM