web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

No record found.

News and Announcements icon
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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Stars!

Congratulations to our 2025 Community Spotlights

Thanks to all of our 2025 Community Spotlight stars!

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

#1
Pallavi Phade Profile Picture

Pallavi Phade 102 Super User 2026 Season 1

#2
11manish Profile Picture

11manish 55

#2
Abhilash Warrier Profile Picture

Abhilash Warrier 55 Super User 2026 Season 1

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans