How to call a decision table from email client template recipients To field

mfhaciahmetoglu
Mega Sage

Hello,

 

Based on the "taxi company" field's choice list value, I want to return a different email address on Email Client Script > Recipients > To field.

 

Any ideas how can this be done?

 

One note related to this.

 

I have already created a script include to call from To field.

 

Script include:

 

// Script Include (Client Callable)
var UserEmailUtil = Class.create();
UserEmailUtil.prototype = {
    initialize: function() {
    },

    getEmailAddress: function() {
        gs.info("is this working?");
        return "test@example.com";
    },

    type: 'UserEmailUtil'
};
 
To field:
mfhaciahmetoglu_0-1738768415033.png

 

For some reason this does not work. I see that gs.info is not displayed either. 

 

Any ideas why? (my app is a custom app, so the scope is not global).

 

Best,

Firat

 

 

2 ACCEPTED SOLUTIONS

Are the email client template and the script include in the same scope? The script include is not accessible form all application scopes.

View solution in original post

Hi @Sheldon  Swift ,

 

I made the script include accessible from all scopes and then used the scope API before calling, then it worked fine.

 

But it is still a mystery why it does not work when it is accessible only from the scope application 😕

 

Best,

Firat

View solution in original post

18 REPLIES 18

I was able to solve the logs error by adding the API: javascript: new x_banv_request_t_0.UserEmailUtil().getRecipientsForTo(current); but still nothing returns. the script is not executed! Very weird 😕

Are the email client template and the script include in the same scope? The script include is not accessible form all application scopes.

Hi @Sheldon  Swift 

 

Sorry, I accidentally clicked accept as solution and cannot undo it :/.

 

But yes they are in the same scope.

 

I am also doing this on the Sandbox instance. I came to know that there is a property called glide.script.use.sandbox: Run client generated scripts (AJAXEvaluate and query conditions) inside of a reduced rights "sandbox". If enabled, only those business rules and script includes with the "Client callable" checkbox set to true are available and certain back-end API calls are disallowed.

 

Can it be related to this?

The script sandbox property is enabled in my instance, so I'm not sure that's related. I've also recreated the client email template and script include in private scope and that is working as expected. If possible, I recommend recreating the client template and script include in the global scope and testing to determine if it is a scope issue.

 

Also, have you set an identifiable subject in the client email template, so you can easily see that it's being applied?

You are right, it is related to the scope. I called it successfully without even flagging as Sandbox callable and it worked just well on Sandbox. But for some reason, scope does not allow it. It is weird because both the script include and the client template are o the same scope!