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’m not sure that’s true. The OOB example, EmailClientTemplateEvaluator, isn’t client callable. I’ll test tomorrow if I get a chance…it will be interesting to know.

Hi @Sheldon  Swift  and @Ankur Bawiskar 

 

Thanks a lot for your help!

 

I tried both of your suggestions but none worked. I cannot even get to print the gs.info, which means that probably I cannot even call it.

 

mfhaciahmetoglu_0-1738852741942.png

I tried this " javascript:" as well.

I tried is client called and not-callable, but in all cases, got this: From field in client template [Taxi Request Template] evaluates to an invalid address []. Using default from address

Any idea why?

 

Thanks.

 

Best,

Firat

 

Hi Firat, are you sure template you're working on is the template being applied? You can try setting some identifying text in the subject to be sure.

 

Also, the forum here automatically encodes the colon as a security mechanism. Usage is as pictured - ":" should be ":" and usage with your class name (note the method names) is as pictured.

 

SheldonSwift_1-1738853600924.png

@Ankur Bawiskar, the below is working as expected in this scenario. I anticipate the requirement will be similar to the OOB example, where @mfhaciahmetoglu will extract a value and execute a GlideRecord query to retrieve the appropriate email address.

 

SheldonSwift_0-1738852970143.png

 

Hey @Sheldon  Swift ,

 

Many thanks again for following-up.

 

I followed exactly the same approach (except that my script include is in my custom application scope)

mfhaciahmetoglu_0-1738853718071.png

And here is the recipients:

mfhaciahmetoglu_1-1738853777664.png

Here is the result:

mfhaciahmetoglu_2-1738853821506.png

I get the following logs:

mfhaciahmetoglu_3-1738853934927.png

Best,

Firat