How to call an flow action in portal menu application

divya19
Tera Contributor

Requirement: In the portal there is an application menu on the header whenever I click on that menu it should redirect to other URL and they will send response through payload that menu items need to display in application menu.so,I have created a flow action to get a response from the URL, now I want to call this action in server script of portal menu and should align menu items here from response. Can anyone help me with the script.

divya19_0-1665913930658.png

 

1 ACCEPTED SOLUTION

OlaN
Giga Sage
Giga Sage

Hi,

Open the action in Flow Designer, click on the button in the top right corner ".." then click on create code snippet.

flow-code-snippet.png

View solution in original post

3 REPLIES 3

OlaN
Giga Sage
Giga Sage

Hi,

Open the action in Flow Designer, click on the button in the top right corner ".." then click on create code snippet.

flow-code-snippet.png

divya19
Tera Contributor

Hi,

 

Thank you for the information. I am trying below script, but it is not working. I am not able see the application menu itself in the portal. After saving this script.Could you please help me on this.

 

(function() {
var menu_id = $sp.getValue('sp_rectangle_menu'); // instance sys_id
var gr = new GlideRecord('sp_instance_menu');
gr.get(menu_id);
data.menu = {};
data.menu.items = $sp.getMenuItems(menu_id);
var response_body;
try {

// Start Asynchronously: Uncomment to run in background. Code snippet will not have access to outputs.
// sn_fd.FlowAPI.getRunner().action('global.bt__menunav_api').inBackground().run();

// Execute Synchronously: Run in foreground. Code snippet has access to outputs.
var result = sn_fd.FlowAPI.getRunner().action('global.bt__menunav_api').inForeground().run();
var outputs = result.getOutputs();

// Get Outputs:
// Note: outputs can only be retrieved when executing synchronously.
var response_body = outputs['response_body']; // String

} catch (ex) {
var message = ex.getMessage();
gs.error(message);
}
var menuNavObj = JSON.parse(response_body);
//var sideNavObj = JSON.parse(sideNavVal);
data.sideNavMenuArr = menuNavObj.result.data.menu;

})();

 

divya19_0-1665940898893.png

 

Sorry, I'm not very good at Service Portal. Hopefully someone else can pick up the thread.

Or you can ask another (more specific) question.

As far as I can help, I gave you the answer on how to call a Flow action through script.