Skip to main content

Notifications

Customer experience | Sales, Customer Insights,...
Suggested answer

Changing field to certain value triggered by person being part of a subscription list.

(0) ShareShare
ReportReport
Posted on by 45

Hey guys!

I really need your help!

My problem is: As soon as a person is part of a subscription list, a certain field in the contact form should be changed to a certain value. is there any way to achieve this? 
it would be reeeeeally important for us to fix that problem. 

thanks for your help! 

Greetings 
Amelie

  • Suggested answer
    cloflyMao Profile Picture
    cloflyMao 25,202 on at
    RE: Changing field to certain value triggered by person being part of a subscription list.

    Hi Amelie,

    There is an entity Listmember which saves all mapping records between contact and marketing list.

    e.g:

    List A contains 3 memebers, list B contains 2 members, thus there will be 5 listmember records in system.

    Listid             Memberid

    • List A id     contact 1 id.

    • List A id     contact 2 id.

    • List A id     contact 3 id.

    • List B id      contact 1 id.

    • List B id      contact 2 id.

    If there is a listmember record which its listid field equal to list B id and its memberid field equal to contact 1 id,

    then it indicates that conact 1 is part of list B

    Thus we could do it with JavaScript:

    Create a JScript web resource with code below and add it to Contact form.

    function listmemberChecker(executionContext) {
    
        var formContext = executionContext.getFormContext();
    
        // Get current contact id
        var id = formContext.data.entity.getId().replace(/\{|\}/gi, "").toLowerCase();
    
        // Check whether there is association between contact and the specific marketing list
        var query = "?$filter=_listid_value eq '006552d4-7eb6-ea11-a812-000d3ab64f2b' and _entityid_value eq "   id   "";
    
        Xrm.WebApi.retrieveMultipleRecords("listmember", query).then(
            function success(result) {
                if (result.entities.length > 0) {
                    formContext.getAttribute("xxx").setValue("some value");
                }
            },
            function (error) {
                console.log(error.message);
            }
        );
    
    }

    We can get a subscription list id in URL.

    1374.JPG

    If retrieved result length is larger than 0, then set a certain field to a certain value.

    Please take tutorial below for how to add a javascript web resource to form.

    https://carldesouza.com/how-to-use-formcontext-in-a-web-resource-in-dynamics-365-power-apps/

    Regards,

    Clofly

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

Announcing Our 2025 Season 1 Super Users!

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

Announcing Forum Attachment Improvements!

We're excited to announce that attachments for replies in forums and improved…

Vahid Ghafarpour – Community Spotlight

We are excited to recognize Vahid Ghafarpour as our February 2025 Community…

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,971 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 230,846 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans