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. 

  • 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

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Women in Power Builds Momentum

Expanding mentorship, skilling, and AI innovation

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

#1
11manish Profile Picture

11manish 42 Super User 2026 Season 2

#2
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 39 Super User 2026 Season 2

#3
Travis South Profile Picture

Travis South 27

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans