The CreatorCon Call for Content is officially open! Get started here.

Auto-Populating field only working for ITIL users and admin

Kai Tingey
Tera Guru

Hi All

We have a client script that we use in a couple of catalog items, that takes the expiry date for the selected user (based on another reference field to select a user) and shows it in a read only field.

I've noticed during testing (we are pre go-live) that it works fine for ITIL users and admins, but not for standard users.

By default the user field populates to whoever is logged in. In this case it will work.

e.g. i am logged on as a standard user who has an account expiration, i can see my expiration date in the field. If i change the selected user to another user who also has an expiry, the field will not populate with their expiry - it becomes blank. If i set it back to myself, it will return the correct expiry again.

If i am logged on as an ITIL user or Admin, it works no matter who you select.

I suspect some kind of security issue on the sys_user table is preventing standard users from seeing the values for others. I am wondering, if this is the case - and if so is there an easy way to give standard users RO permissions to this field?

The client script is as follows .

function onChange(control, oldValue, newValue, isLoading) {
if ( newValue == '') {
return;
}

var GateExpiry = g_form.getReference('u_Contractor', getDate);
function getDate(GateExpiry)
{
g_form.setValue('u_account_current_expiry', GateExpiry.u_expiry_end_date);
}
g_form.setReadOnly('u_account_current_expiry', true);
//g_form.setMandatory('u_account_current_expiry', true);

}

1 ACCEPTED SOLUTION

Kai Tingey
Tera Guru

Hi All

We managed to resolve this, it was an ACL issue. thanks

View solution in original post

3 REPLIES 3

Ahmmed Ali
Mega Sage
Mega Sage

Hello,

 

Avoid using getReference() as it is synchronous server call. It can impact the performance.

instead use glideAjax for asynchronous() server call.

 

Please find below docs for more details.

https://docs.servicenow.com/bundle/geneva-servicenow-platform/page/script/server_scripting/reference/r_ExamplesOfAsynchronousGlideAjax.html

 

Let me know for any query.

 

Cheers!!!

Ali

If I could help you with your Query then, please hit the Thumb Icon and mark my answer as Correct!!

Thank you,
Ali

Kai Tingey
Tera Guru

Hi All

We managed to resolve this, it was an ACL issue. thanks

Anita Parrott
Kilo Contributor

Hi Kai

I have this exact same issue, can you remember which ACL it was that caused you the problem?

Thanks

Anita