Can I control (make readonly/mandotory...) variables inside a multi row variable set

F_bio Santos
Kilo Sage

Can I control (make readonly/mandotory...) variables inside a multi row variable set with a catalog ui policy inside the item and not inside the variable set ?

Im trying to make a variable that in inside a MRVS read-only based on the value of a field that is on the item is this possible ? (Zurich Version)

1 ACCEPTED SOLUTION

Brad Bowman
Kilo Patron
Kilo Patron

Seems backwards and unnecessary, since the values in each row are already read-only when viewed on the Catalog Item form.  Just create an onLoad Catalog Client Script that applies to the MRVS, which will run when the Add Row button or Edit icon is clicked - so it will be in effect in the add/edit row dialog window:

function onLoad() {
    if (g_service_catalog.parent.getValue('var_name') == 'create') {
        g_form.setValue('add_remove', 'add');
        g_form.setReadOnly('add_remove', true);
}

 

View solution in original post

7 REPLIES 7

Matthew_13
Tera Guru

Can you control MRVS variables with a catalog UI Policy on the item?

  • No 😞 , not directly. In Zurich, UI Policies on the catalog item do not automatically apply to MRVS variables, because they live in a subform.

Workarounds:

  1. Client Script on the catalog item

    • Use an onLoad/onChange script to loop through MRVS rows and set read-only/mandatory dynamically.

     
    g_form.getValue('item_field'); g_form.getSections('mrvs_name').forEach(function(row){ g_form.setReadOnly('mrvs_variable', true/false, row); });
     
  2. UI Policy inside the MRVS

    • Use a hidden variable to pass conditions from the catalog item, then the MRVS UI Policy can act based on that.

At the End of the Day:

  • Catalog-level UI Policies can’t directly control MRVS variables in Zurich.

  • You need a client script on the item or a UI Policy inside the MRVS for dynamic behavior.

@F_bio Santos  - Please give a Thumbs up and Accepted Solution if you find Helpful! Thanks My Friend!

Hi @Matthew_13 so would something like this work ?

Also I want this to happen before the row is added, I want the "add_remove" to be "add" and "readonly" when the item variable value is "create", so that users can only use "add" when adding a new row.

(On the CI side)

if (newValue === 'create') {

	g_form.getSections('access_managment').forEach(function(row){ g_form.setValue('add_remove', 'add', row); });
	g_form.getSections('access_managment').forEach(function(row){ g_form.setReadOnly('add_remove', true, row);});

    }



 

Yes 🙂 , that approach should work!

You’re looping through each row in the access_managment MRVS and:

  • Setting the add_remove variable value to 'add'

  • Making the add_remove variable read-only

Just make sure:

  • This runs at the right time (like onChange of the field controlling newValue)

  • The variable and section names are spelled exactly as in your form

  • You test it on multiple rows to confirm it applies everywhere

If you want, I can help you tidy it up or add a check to handle other newValue cases.

 

@F_bio Santos  - Please give a Thumbs up and Accepted Solution if you find Helpful! Thanks My Friend!

I must be doing something wrong, Im getting this error:

Error while running Client Script "Action = Create (Add/Remove)": TypeError: Cannot read properties of undefined (reading 'forEach')


I went to check if the internal name of the "MRVS" was right and it is ðŸ¤”