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 CRM (Archived)

Set regarding activity from another field

(0) ShareShare
ReportReport
Posted on by

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

I have the same question (0)
  • Community Member Profile Picture
    on at

    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?

  • Community Member Profile Picture
    on at

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

  • Community Member Profile Picture
    on at

    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?

  • Suggested answer
    Shidin Haridas Profile Picture
    3,499 on at

    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
    on at

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

  • Suggested answer
    Community Member Profile Picture
    on at

    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
    on at

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

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!

Meet the Microsoft Dynamics 365 Contact Center Champions

We are thrilled to have these Champions in our Community!

Congratulations to the March Top 10 Community Leaders

These are the community rock stars!

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

#1
JS-09031509-0 Profile Picture

JS-09031509-0 3

#2
AS-17030037-0 Profile Picture

AS-17030037-0 2

#2
Mark Eckert Profile Picture

Mark Eckert 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans