Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics 365 | Integration, Dataverse...
Answered

Update email to field with single line of text field value

(0) ShareShare
ReportReport
Posted on by 344

I have an issue with JavaScript populating a text field value into "To" lookup in the email form. Current code works fine in the classic interface but it's not working in UCI. Here is the existing code which gets an email address from category field and populates "To" field. 

function addEmailAddress(executionContext) {
var formContext = executionContext.getFormContext();
var emailAddress = formContext.getAttribute("category").getValue();
var obj = new Object(); //create the unresolved object
obj.name = emailAddress;
obj.category = 3;
obj.data = emailAddress;
obj.type = "9206";
var toField = formContext.getAttribute("to");
toField.setValue([obj]); //if 'to' field is null, just override it
}

Any solutions would be greatly appreciated. 

  • scopecrm Profile Picture
    344 on at
    RE: Update email to field with single line of text field value

    perfect, Thanks Andrew.

  • Verified answer
    a33ik Profile Picture
    84,329 Most Valuable Professional on at
    RE: Update email to field with single line of text field value

    Hello,

    Try to use following in UCI interface:

    function addEmailAddress(executionContext) {
        var formContext = executionContext.getFormContext();
        var emailAddress = formContext.getAttribute("category").getValue();
        
        var unresolved = {
            entityType: "unresolvedaddress",
            id: "{00000000-0000-0000-0000-000000000000}",
            name: emailAddress
        };    
        
        var toField = formContext.getAttribute("to");
        toField.setValue([unresolved]); //if 'to' field is null, just override it
    }

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Daivat Vartak – Community Spotlight

We are honored to recognize Daivat Vartak as our March 2025 Community…

Announcing Our 2025 Season 1 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Kudos to the February Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 293,099 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 231,884 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156 Moderator

Leaderboard

Product updates

Dynamics 365 release plans