Trying to access a sys_property from a metric

Richard Thomas2
Tera Contributor

Hi Experts,

I'm trying to access a system property containing sys_ids of catalog items in a metric definition. However, everything I've tried so far isn't working. Code is below - any help is appreciated! 

 Thank you!

 

var metricValues = gs.getProperty('sli_metrics');

var array = metricValues.split(",");

gs.info('Array RT' + array);

var s = current.state;
var requestItemId = current.request_item.cat_item;
gs.info('Request Item IF: ' + requestItemId);

for (var i = 0; i < array.length; i++) {
    var arrString = array[i].toString();
    gs.info('Array RT2' + array[i]);
   
    if ( arrString === requestItemId && (s == 3 || s == 4 )) {
        gs.info(true + ' ' + requestItemId);
        createMetric();
    }

   
4 REPLIES 4

Jaspal Singh
Mega Patron
Mega Patron

Hi Richard,

Metric is on which table? I assume it to be Catalog Task. Also, I see you have added log statements. What is that is generated in the logs.

Richard Thomas2
Tera Contributor

Hi Jaspal - thanks for your reply.

Yes it's on the catalog task table. the Logs are returning the sys_ids as required but the script is not working as it's generating metrics for all sc tasks created

Anand Kumar P
Giga Patron
Giga Patron

Hi @Richard Thomas2 ,

Insted of toString () try replacing with below one

var arrString = array[i].trim();

And after createMetric() use break;

 

Mark it as helpful and solution proposed if it serves your purpose.
Thanks,
Anand

Hi Jaspal, 

Not it's still not working I'm afraid :(. Will keep trying!