- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-03-2022 06:51 AM
Hi everyone,
is it possible to execute server side code from a button on a dashboard in workspace via ui builder coding?
For example I want to achieve to add a button on this dashboard via ui builder (dont know if possible) and when I click on this button a server side code should execute a workflow via the workflow api with the sys_id of the open record and for example start a request of this or retire this software model.
I know I can execute client script code via a component but can I trigger a workflow too?
Thanks for your help in advance.
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-03-2022 11:59 AM
Yes you can trigger a workflow via the page script. You will need to:
- In Flow Designer,
- create a Subflow
- then grab the code snippet from the Subflow editor
- In Scripted REST API,
- Create a REST API that calls the Subflow using the code snippet previously created
- In UIB,
- Add a page script that calls the REST API using the function snHttp
- See: Documentation helpers - helpers.snHttp(String url, Object options)
- In the script you can refer to the current sysId by calling
api.context.props.sysId
- Add a button
- Go to the click event and call the Page Script
Typically the sys id can be retrieved by calling api.context.props.sysId however in your case you might be able to retrieve the sysId of the current record through a page property.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-03-2022 11:59 AM
Yes you can trigger a workflow via the page script. You will need to:
- In Flow Designer,
- create a Subflow
- then grab the code snippet from the Subflow editor
- In Scripted REST API,
- Create a REST API that calls the Subflow using the code snippet previously created
- In UIB,
- Add a page script that calls the REST API using the function snHttp
- See: Documentation helpers - helpers.snHttp(String url, Object options)
- In the script you can refer to the current sysId by calling
api.context.props.sysId
- Add a button
- Go to the click event and call the Page Script
Typically the sys id can be retrieved by calling api.context.props.sysId however in your case you might be able to retrieve the sysId of the current record through a page property.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-03-2022 11:47 PM
Hi
This sounds good. I will try to work on this instruction you gave me. I come back if I have some problems.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-08-2022 07:26 AM
Hi @Marc Mouries
What do you mean with page property? And how can I pass the retrieved sysid to the subflow?
Thanks for your help.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-27-2022 09:19 PM
hate to necro the thread,
but ...
what about 'putting backend logic on a smart button click, from agent mobile app' ??