How to pass data from client script to workspace Ui Action

ManikandanP7586
Giga Contributor

I'm facing an issue where I need to pass data from a UI Page Client Script to a Workspace Client Script callback function, i referred community articles but this wasn't helpful.

1 ACCEPTED SOLUTION

Ankur Bawiskar
Tera Patron
Tera Patron

@ManikandanP7586 

did you explore few of the OOTB UI actions?

somewhere the logic must be present.

you can use callback method, I believe ServiceNow uses iframeMsgHelper for this

Search with UI page client script contains -> iframeMsgHelper

UI page client script using that and including the data to be passed

AnkurBawiskar_0-1754404472331.png

 

Then in workspace client script, it's accessed like this

AnkurBawiskar_1-1754404501990.png

 

OOTB UI page: time_sheet_recall_dialogue

OOTB UI action: Recall (time_card) table

AnkurBawiskar_2-1754404627063.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

View solution in original post

6 REPLIES 6

kaushal_snow
Mega Sage

 

Workspace UI Action can open a UI Page as a modal using g_modal.showFrame(). Within that iframe, your UI Page uses iframeMsgHelper (or window.postMessage) to send data back to the parent workspace modal. Use a Workspace UI Action with a Client Script (client-side, enabled) to call your UI Page. The callback function defined in the Workspace client script receives that data and processes.

 

Try this once and let me know. If you find this helpful, please accept this as a solution and hit the helpful button..

 

Thanks and Regards,
Kaushal Kumar Jha - ServiceNow Consultant - Lets connect on Linkedin: https://www.linkedin.com/in/kaushalkrjha/

Ankur Bawiskar
Tera Patron
Tera Patron

@ManikandanP7586 

did you explore few of the OOTB UI actions?

somewhere the logic must be present.

you can use callback method, I believe ServiceNow uses iframeMsgHelper for this

Search with UI page client script contains -> iframeMsgHelper

UI page client script using that and including the data to be passed

AnkurBawiskar_0-1754404472331.png

 

Then in workspace client script, it's accessed like this

AnkurBawiskar_1-1754404501990.png

 

OOTB UI page: time_sheet_recall_dialogue

OOTB UI action: Recall (time_card) table

AnkurBawiskar_2-1754404627063.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

@ManikandanP7586 

Hope you are doing good.

Did my reply answer your question?

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

In my case, the functionality works correctly in Native UI, but in Workspace, I'm unable to retrieve the values as expected.

My requirement is: when a modal opens, it displays some fields. Based on the data entered in those fields, a GlideAjax call is triggered to create a record and return the sys_id and i set it to one field using g_form.setValue().

While the sys_id is successfully returned in Workspace, I'm unable to retrieve or use it properly within the Workspace client script. I’ve tried using iFrameHelper and postMessage, but those approaches didn’t work.



ManikandanP7586_0-1754477785374.png

@Ankur Bawiskar , @kaushal_snow