UI Action workspace script - how to get values from variable fields on workspace form

mattburgess
Tera Expert

Hi 

 

Does anyone know how to access variable fields in Request Item / Catalog Task on Service Operations workspace when checking using a UI Action > Workspace client script 

 

The traditional way of accessing variables doesnt seem to work in workspace.....

 

i.e. Native

 

g_form.getValue('variables.VARIABLE_NAME')

 

Workspace

 

??

 

 

1 ACCEPTED SOLUTION

mattburgess
Tera Expert

Hi - ok so we have figured out that we will need to hide the UI Action button in SOW through UI Action visibility as the logic in native UI Action will not work the same way in Workspace without serious rework (i.e. using GlideAjax to do the logic to check if all variables are filled in etc)

 

Then we are going to create a Declarative Action (DA) to mimic the same behavior in Workspace and set that visible on the SOW form.

 

Thanks for your help.

 

It does seem that reworking complex UI action scripts in SOW is very difficult and therefore using DA to do the same logic for workspace seems the right approach.

 

Agree?

 

 

View solution in original post

12 REPLIES 12

@mattburgess 

have you configured the variable editor so that it's visible in workspace view as well and then try that script?

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

@mattburgess 

I am able to get the variable value

1) RITM form has variable editor in configurable workspace in workspace view

 

AnkurBawiskar_2-1735900255016.png

 

2) I wrote onLoad client script on sc_req_item table and is able to access the value of variable "Application Type"

AnkurBawiskar_3-1735900285064.png

 

 

AnkurBawiskar_0-1735900197678.png

 

AnkurBawiskar_1-1735900213583.png

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

Yes on a client script itself it should be ok as you can run as ALL.

 

But my use case is UI Action button "close" so UI Action button has 2 client scripts

 

- Native

- Workspace

 

Also you need to tick to create a second UI Action button for workspace so you see 2 close buttons...not ideal.

@mattburgess 

when you want UI action logic in workspace you need to write in workspace client script.

why 2 close buttons?

It's single button but in backend system creates a UX button which works in workspace

What's your challenge? I didn't get it

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

mattburgess
Tera Expert

Variable editor is available in SOW workspace on RITM and catalog task 

 

But when i am trying to script g_form methods for variables inside the editor such as getValue and setValue and setMandatory it doesnt seem to recognise those variables from the workspace client script.

 

Basically my ask is to prevent closure if specific variables are not completed.  

 

- Check Variables value

- If empty

- Set Mandatory variables and prevent closure

 

 

This works for UI Action close button in Native UI (as it is also visible in SOW)

 

But I need to also add some additional logic to include modal pop up in SOW so i had to add a new workspace Close button as g_modal doesnt work in native client script. Hence i need to also then mimic the same behaviour in workspace client script.