To get UserID in Onchange() Client Script
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-30-2023 08:36 AM
Hi All,
I have a "request for" reference field in that field default value is logged in userid. So, If I select "exists"(its a checkbox) as No, then request for should be cleared. When I select back to "exists" as 'Yes' then UserID should be populated.
Can anyone help me to achieve this.
Thanks in advance
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-30-2023 09:17 AM
Hi,
Write a ui policy if exists is true as below. use exists in place of active
click advanced and write a condition
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-30-2023 09:24 AM
@Ashok32 ,
Please try below mentioned code:
Client Script : on change
variable: on check Box(exist)
script:
if(newValue+"" == "true"){
g_form.setValue('requested_for',g_user.userID);
}else{
g_form.clearValue('requested_for');
}
Please mark my answer helpful, if it works for you.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-30-2023 09:25 AM
Hi Not sure about check box but you make attachments mandatory by using the checkbox in catalog item as below
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-30-2023 09:25 AM - edited 01-30-2023 09:25 AM
Try this
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
var ref = g_form.getValue('<ecists field>'); // use correct field anme
if(ref == 'Yes') //make sure you use correct value
g_form.setValue('<requested_for>', g_user.userID); // use correct field anme
else
g_form.clearValue('<requested_for>'); // use correct field anme
}