web
You’re offline. This is a read only version of the page.
close
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. 

I have the same question (0)
  • Verified answer
    a33ik Profile Picture
    84,331 Most Valuable Professional on at

    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
    }

  • scopecrm Profile Picture
    344 on at

    perfect, Thanks Andrew.

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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > Microsoft Dynamics 365 | Integration, Dataverse, and general topics

#1
Martin Dráb Profile Picture

Martin Dráb 58 Most Valuable Professional

#2
#ManoVerse Profile Picture

#ManoVerse 42

#3
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 38 Super User 2025 Season 2

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans