How to check/validate if a variable is read-only on service portal view?

aman_sharma_07
Tera Guru

Hi all!

 

I'm looking for a way to check if a variable is read-only on client side.

 

Any idea how that can be done?

 

Thanks!

1 ACCEPTED SOLUTION

@Ankur Bawiskar ,

Actually, it's a bit complicated logic which we have put in place.

 

We have a review feature for non-fulfillers, on the same form which is used to submit the request.

For your information, we have a client script (CS3) available for setting the variable values only(not making read-only), which triggers on change of var_a, other than that of var_e.

For review feature to work, we are only setting the value in var_a , so it can trigger the already developed client script.

 

So let me summarize this:

onLoad (CS1) -> set the value in var_a -> triggers the (CS3) -> sets the value in all variables, including var_e -> triggers the (CS2) -> sets the variables read-only, except var_e and clears the value.

 

Now coming to your suggestion;

  1. CS2 & CS3 can't be merged as it would dissolve the functionality of CS3, which is required independent for other use cases (where the variables shouldn't be read-only).

I'm thinking not to reuse this feature and re-build the functionality once again in the CS1 itself, and exclude var_e setting and resetting feature there.

 

Thanks for your help!
Regards,

Aman Sharma

View solution in original post

7 REPLIES 7

@aman_sharma_07 

why to have 2 CS?

your 2nd CS is on running on last variable just to make variables read-only except that var_e

So please combine both logic in 1 CS i.e. onChange of your variable

don't set the var_e and don't make it readonly

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

@Ankur Bawiskar ,

Actually, it's a bit complicated logic which we have put in place.

 

We have a review feature for non-fulfillers, on the same form which is used to submit the request.

For your information, we have a client script (CS3) available for setting the variable values only(not making read-only), which triggers on change of var_a, other than that of var_e.

For review feature to work, we are only setting the value in var_a , so it can trigger the already developed client script.

 

So let me summarize this:

onLoad (CS1) -> set the value in var_a -> triggers the (CS3) -> sets the value in all variables, including var_e -> triggers the (CS2) -> sets the variables read-only, except var_e and clears the value.

 

Now coming to your suggestion;

  1. CS2 & CS3 can't be merged as it would dissolve the functionality of CS3, which is required independent for other use cases (where the variables shouldn't be read-only).

I'm thinking not to reuse this feature and re-build the functionality once again in the CS1 itself, and exclude var_e setting and resetting feature there.

 

Thanks for your help!
Regards,

Aman Sharma

Ankur Bawiskar
Tera Patron
Tera Patron

@aman_sharma_07 

for portal there is no direct way, you will have to use custom variable and add widget to it and then use client controller script etc.

Includes lot of customizations.

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader