Trying to parse ui builder indicators metric values to a service catalog via url

archanachil
Tera Contributor

Hi ,

 

We have a dashboard built using metrics from pa indicators using ui builder.

We are trying get those metrices value on to a service now catalog item variables.

 
 
/**
  * @Param {params} params
  * @Param {api} params.api
  * @Param {TransformApiHelpers} params.helpers
 
function evaluateProperty({api, helpers}) {
  return '';
}*/

function openCatalogItemWithMetric() {
 
  var metricValue = g_form.getValue('@data.verticalA_headlinemetric2.output.result.0.value_unit');
var metricValue2 = g_form.getValue('@data.getmetricsofciodashboard.output.VerticalA.headlineMetrics.1.metricLabel');
 

  // Construct the catalog item URL using template literals

url += '&sysparm_metricValue=' + metricValue;

url += '&sysparm_metricValue2=' + metricValue2;

  window.open(url, '_blank');
}
 
 
here in the script , 
var metricValue = g_form.getValue('@data.verticalA_headlinemetric2.output.result.0.value_unit');
var metricValue2 = g_form.getValue('@data.getmetricsofciodashboard.output.VerticalA.headlineMetrics.1.metricLabel');
 these 2 lines are getting failed.
 
 
here @Data.verticalA_headlinemetric2.output.result.0.value_unit' -- this is the data source vale of metric used in one of the component of the dashboard which needs to be passed to catalog item variable.
archanachil_0-1721329250064.png  archanachil_1-1721329280441.png

 

 

 

we are trying to invoke this via link , whenever they click on link report link they needs to be redirected to the catalog item and show up the metrics value on one of it variable(autopopulate).

 

archanachil_2-1721329452474.png

 

 

can any one help with suggestions in the code , as it is failing to pass the value to the url.

 

Thanks in advance!!

 

next update ---------------------------------------------------------------------------
 

Hi ,

 

We have created a script that is running on ui builder link but when we actually go to dashboard and try to click on the huperlink its not redirecting to expected instead it is opening homepage. 

code which worked 

 

function openCatalogItemWithMetric({api}) {
var metricValue = api.data.verticalA_headlinemetric2.output.result[0].value_unit;
var metricValue2 = api.data.getmetricsofciodashboard.output.VerticalA.headlineMetrics[1].metricLabel;
const catalogItemUrl = `https://cognizantdemo7.service-now.com/sp?id=sc_cat_item&sys_id=6389e9f31b9b0a10660477f58d4bcb7e&sys... encodeURIComponent(metricValue) + '&sysparm_metricValue2=' + encodeURIComponent(metricValue2);

window.open(catalogItemUrl, '_blank');
}

can anyone tell us how to trigger trigger this script when the link on the dashboard is clicked,, tried event handling but didn't succeed . any suggestions or script or process changes please let us know

1 REPLY 1

archanachil
Tera Contributor

Hi ,

 

We have created a script that is running on ui builder link but when we actually go to dashboard and try to click on the huperlink its not redirecting to expected instead it is opening homepage. 

code which worked 

 

function openCatalogItemWithMetric({api}) {
var metricValue = api.data.verticalA_headlinemetric2.output.result[0].value_unit;
var metricValue2 = api.data.getmetricsofciodashboard.output.VerticalA.headlineMetrics[1].metricLabel;
const catalogItemUrl = `https://cognizantdemo7.service-now.com/sp?id=sc_cat_item&sys_id=6389e9f31b9b0a10660477f58d4bcb7e&sys... encodeURIComponent(metricValue) + '&sysparm_metricValue2=' + encodeURIComponent(metricValue2);

window.open(catalogItemUrl, '_blank');
}

can anyone tell us how to trigger trigger this script when the link on the dashboard is clicked,, tried event handling but didn't succeed . any suggestions or script or process changes please let us know