Control typology rule does not have access to the application object | Community
Skip to main content
Level 2
June 15, 2023
Question

Control typology rule does not have access to the application object

  • June 15, 2023
  • 2 replies
  • 1631 views

Hi,

 

I'm trying to use a control typology rule to dynamically set some SMTP headers of the delivery. One of the things I need to do is check the name of an enumeration based on the value configured in the delivery. 

In a test workflow, I was able to get the name using the application get schema method and find the desired enumeration: application.getSchema("nms:recipient")

 

However, when I try to apply the same code in my typology rule it just doesnt find the schema, I suspect that the application object is not available. According to the documentation it should be:

 

The complete code is:

 

function findBounceAddress(vendor){ var schema = application.getSchema("nms:recipient"); var enum = schema.enumerations.filter(findEnum("nms:recipient:vendor")); return findNameFromValue(enum[0].values, vendor); } function findEnum(name){ return function(enumerations){ return enumerations.name.trim() == name; } } function findNameFromValue(values, searchValue){ var result = ""; Object.keys(values).forEach(function(key,index) { if(values[key].value == searchValue){ result = key; } }); return result; }
This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.

2 replies

Level 5
June 17, 2023

Hi @jmeilan ,

I did some research on your query and seems you are not correctly configuring the control typology.

Above code will return value and can you please specify, how you are using the same value to set a rule in control typology.

 

As per your query above, its not much about having application object for control typology or not, its about that you are not returning the correct value which your custom control typology rule wants in same.

 

Can you give some more details of your control typology rule?

 

I am very much sure, rule is not been configured correctly.

 

Note :- JS code in control rule don't work exactly like JS code in workflow activity.

 

Regards

Abhishek

 

 

jmeilanAuthor
Level 2
June 19, 2023

Hi Abhishek,

 

I have an enumeration thas values as integers. The whole point of the above code is to give it a value such as 1 and find the name of that enumeration value such as "firstValue".

 

The reason why I think application is not available it's because when I do the below code I don't even get the schema. So nevermind all the loops and searching, I just don't get the recipient schema object in the first place.

 var schema = application.getSchema("nms:recipient");

 

Maybe the object is different in a typology rule but that code worked fine in a workflow

Level 5
June 19, 2023

Hi @jmeilan ,

Yes I also tried the same code at my end and I am also not getting the recipient schema.

 

It seems it is not available. 

 

Regards

Abhishek

Sukrity_Wadhwa
Community Manager
Community Manager
August 24, 2023

Hi @jmeilan,

Were you able to resolve this query on your own or do you still need help here? Do let us know.

Thanks!

Sukrity Wadhwa
jmeilanAuthor
Level 2
August 24, 2023

Hi @sukrity_wadhwa ,

 

Unfortunately I wasn't able to make it work and I had to use a workaround. It would be good if I could get some clarity on this for my information but it seems from my side that it is not possible

Sukrity_Wadhwa
Community Manager
Community Manager
August 25, 2023

Alright! Thanks for updating us on your issue. I will escalate it among our internal SMEs and see if they can help.

Sukrity Wadhwa