Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics CRM (Archived)

Set regarding activity from another field

Posted on by Microsoft Employee

Hi,

I've tried to customize the "regarding" lookup view by filtering the list, but this causes issues with the outlook addin.

Simple workaround would be to create a new field called account lookup, and have the chosen value update the regarding field, but i guess that value ia somewhat different (account vs object id).

Any thoughts?

*This post is locked for comments

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Set regarding activity from another field

    Tried that, but no change unfortunately. The filter is reset when event is selected.

  • Suggested answer
    Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Set regarding activity from another field

    As you mentioned Event is a custom entity but in your code line it doesn't have a prefix.

    Xrm.Page.getControl("regardingobjectid").addCustomFilter(fetchQuery, "event");

    I think it should look like this:

    Xrm.Page.getControl("regardingobjectid").addCustomFilter(fetchQuery, "xxx_event");

    where xxx is the prefix of the publisher when you created Event Entity.

    To get the correct Entity name for event. Go to Settings>> Customizations>> Customize the system. Click on Events entity and look in Name:

    63811.Capture.PNG

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Set regarding activity from another field

    I am in fact talking about the lookup control of the regarding field. (not partylist).

  • Suggested answer
    Shidin Haridas Profile Picture
    Shidin Haridas 3,497 on at
    RE: Set regarding activity from another field

    Hi,

    I always thought the "addCustomFilter" can be used only on lookup controls and not to partyList controls.

    Maybe that is the reason why the custom filter is not working.

    Keep us posted if you are able to get it working@

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Set regarding activity from another field

    Ok, so ... I customized the appointment view to make easier for the user to get around. We have a custom appointmenttype field which has 5 different values: Distributor, end-user, industry, event, other. Depending on the chosen value, the following things get done:

    - Specific checklist gets shown/hidden (works perfectly)

    - Set regarding field is filtered depending on the type (custom accounttype field in Accounts). This works except for event (= custom entity, but the lookup field shows everything so code is not working somehow) and the fact that you can no longer set a contact.

    This is the code:

    function setAppointmentRegardingLookup()
    {
    
        Xrm.Page.getControl("regardingobjectid").addPreSearch(addFilter);
    }
    
    function addFilter()
    {
        var AppointmentTypeText = Xrm.Page.getAttribute("xx_appointmenttype").getText();
        
        if(AppointmentTypeText == "Visit - Distribution")
    	{
        var fetchQuery = "<filter type='and'><condition attribute='xx_accounttype' operator='eq' value='960800002' /></filter>";
        Xrm.Page.getControl("regardingobjectid").addCustomFilter(fetchQuery, "account");
        }
    
        else if (AppointmentTypeText == "Visit - End-User")
        {
        var fetchQuery = "<filter type='and'><condition attribute='xx_accounttype' operator='eq' value='960800000' /></filter>";
        Xrm.Page.getControl("regardingobjectid").addCustomFilter(fetchQuery, "account");
        }
    
        else if (AppointmentTypeText == "Visit - Industry")
        {
        var fetchQuery = "<filter type='and'><condition attribute='xx_accounttype' operator='eq' value='960800001' /></filter>";
        Xrm.Page.getControl("regardingobjectid").addCustomFilter(fetchQuery, "account");
        }
        
        else if (AppointmentTypeText == "Event")
        {
        var fetchQuery = "<filter type='and'><condition attribute='new_eventid' operator='not-null' /></filter>";
        Xrm.Page.getControl("regardingobjectid").addCustomFilter(fetchQuery, "event");
        }
    }


    So now, there a few solution:

    - Fix the code above so the events do get filtered

    - Somehow get code to set the "look-in" value in the lookup window of "Regarding" based on the appontmentType

    - work the other way: Use the regarding object to set the appointmentType.

    Hope this helps?

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Set regarding activity from another field

    Please share the code your are using to set the regarding object. Account id is same as regardingobjectid.

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Set regarding activity from another field

    In the first place, can you explain what it is that you are trying to achieve? Why were you trying to filter the regarding view and where would you be putting an 'account lookup' field? Is it in relation to one activity type or all?

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

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,280 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,214 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans