UI Action Redirection for form and list acion

malaisamyj
Tera Contributor

Hi All,

I have a requirement as below,

I want to use one UI for both form and List. But when i click the UI action in form it should redirect me to different page when i click in list it has to redirect me to different page. How to achieve this in one UI action. Please help me. Basically it has to identify where the button clicked and based on it has to redirect me.

Help would be appreciated.

Thanks,

malaisamy

6 REPLIES 6

Justin Abbott
Giga Guru

You might be able to use this, depending on what else you need to do. There might be a better way, but this was one way I was able to differentiate.



In the client function, build logic around typeof rowSysId == 'undefined'.



function identifyLocation() {


      if (typeof rowSysId == 'undefined') {


              // THIS SECTION WAS FOR THE LIST ACTION


      } else {


              // THIS SECTION WAS FOR THE FORM ACTION


    }


}


Hi Justin,



Thanks for the reply . If i do this through client function where would i be able to write my server side script which exactly does the action?



Please provide me some sample UI action script which runs in both form and list.



Thanks,


Malaisamy


I have written the same. But its not working,


Please help me to resolve the issue.


find_real_file.png


To do what I did, you'll need to check the Client field and put identifyLocation(); in the client function call field.



This is a good reference on how to include both client and server side code in one UI Action: https://www.servicenowguru.com/system-ui/ui-actions-system-ui/client-server-code-ui-action/