The CreatorCon Call for Content is officially open! Get started here.

Creating a dynamic URL in a Record Producer?

CharlesR1
Kilo Guru

Hello all,

I'm not sure this is possible but we need to create a clickable link on a record producer to enable a new window to open with a URL comprised of static text and values retrieved from the selections made on the form.

We have already created a UI action which performs this task on the main table form, and we have created a UI Macro which provides a link to a static URL on a record producer, but we have not managed to merge the two! Can anyone point me in the right direction?

Thanks very muich,

Charles

Example of our UI Macro:

<?xml version="1.0" encoding="utf-8" ?>

<j:jelly trim="false" xmlns:j="jelly:core" xmlns:g="glide" xmlns:j2="null" xmlns:g2="null">

<a href="https://community.servicenow.com/" target="_blank">Please Click Here</a>

</j:jelly>

Example of our UI Action:

function presentWindow(){

var URL1 = 'http://companyintranet.com/re1/searching.do?aty=';

var URL2 = g_form.getValue('u_test_field');

var URL3 = '&newInfodate=0';

window.open(URL1+URL2+URL3);   /*to open the window in new page*/

  }      

action.setRedirectURL(current);

10 REPLIES 10

Hi Charles,



Thanks for the clarification. I haven't done what you describe, but if I were going to, I'd take a look at other record producers/catalog items to see which use UI macros in the variable list and if any of those UI macros have consumed variables from the parent record producer/catalog item. In short, are there any OOB examples?


Hi Chuck,



Yes I did have a look, but we have only two others out of box, both 'contextual_search_results', which are no help unfortunately.



Thanks,



Charles


CharlesR1
Kilo Guru

Thanks for your input Chuck. Does anyone else have any idea how this might be done?



Thanks for any suggestions!



Ch


Kannan Nadar
Tera Guru

Hello Charles,



Try to write a client script in your UI Macro which will have a function with parameters. On your form, you have a catalog client script onChange (maybe) then call that function by passing parameters. Now your data from the form is available in your UI Macro function, you can use DOM manipulation to set values to the fields on the UI Macros.



Thanks,


Kannan


Thanks Kannan,



This is not something we have done before - are there any examples of the type of catalog client script and UI Macro that we would need to create?



Thanks,



Ch