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

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

Dynamics 365 Portal: Button Filter Criteria for logged user...

(0) ShareShare
ReportReport
Posted on by 47

Hi All, 

Help! Is it possible to hide/show Action Buttons on forms based on the logged user? I was thinking that injecting the {{user.id}} into the fetchxml entered within the Button's Filter Criteria should work.... but it's not working. It seems the Filter Criteria only accepts fetchxml. Is this correct? The fetchxml works with hard-coded GUID or without the logged user condition but this is needed because different users will have access to the same view. Splitting entity forms/views by user does not apply here. Example: A delegated user must be able to interact with all records but can ONLY SUBMIT his own record. 

Here is my current fetchxml with hardcoded GUID:

<fetch version="1.0" output-format="xml-platform" mapping="logical" distinct="false">
<entity name="www_plan">
<attribute name="www_planid" />
<filter type="and">
<condition attribute="statuscode" operator="eq" value="1" />
<condition attribute="www_contactid" operator="eq" uitype="contact" value="{4440EF99-8436-E811-A95D-000D3EE46927}" />
</filter>
</entity>
</fetch>

Tried: <condition attribute="www_contactid" operator="eq" uitype="contact" value="{{ user.id }}" />

No luck! 

Thanks in advance for your help!

Tim

*This post is locked for comments

I have the same question (0)
  • Suggested answer
    Kalpavruksh D365 CoE Profile Picture
    2,545 on at
    RE: Dynamics 365 Portal: Button Filter Criteria for logged user...

    Hi Tim,

    While logging in the portal, contacts are configured hence you will not be able to get guids of the user table to show/hide button. You can set one flag on Contact and can access that flag value to show/hide button based on the true or false value of that flag.

  • Tim Made Profile Picture
    47 on at
    RE: Dynamics 365 Portal: Button Filter Criteria for logged user...

    Hi Kalpavruksh,

    Thanks for your response. Only that this has to be a filter on the logged user. The button toggle is determined by comparing the logged user to the contactid of each record in the Entity List or Form. Hence it will show/hide if there is a match. We can pass the Logged User ID to js in the Custom Javascript area... we should also be able to pass the same to the Filter Criteria of the Action Buttons. Don't know if anyone has been able to do this before somehow. Please heeeelp!

    Thanks!

  • Suggested answer
    Nicholas Hayduk Profile Picture
    2,863 on at
    RE: Dynamics 365 Portal: Button Filter Criteria for logged user...

    Hi Tim,

    Unfortunately I don't think this is possible.

    As you pointed out, it doesn't look like any Liquid code within the FetchXML is evaluated.

    Another possibility that may have worked was inserting any contact into the query - this works for the filter criteria specified for view, as the Portal code will dynamically replace that ID with the ID of the currently logged in contact, however as you mentioned, that doesn't work either.

    Based on what I see in the code, it doesn't look like the FetchXML is processed in any way, except to add the condition of filtering on that specific ID of the row it's looking at (for reasons I mention in my blog post at www.engineeredcode.com/.../dynamics-365-portal-filter-criteria-and-action-buttons).  So at this point, I don't think it is possible.

    Nick

  • Suggested answer
    Ulrikke Akerbaek Profile Picture
    5 on at
    RE: Dynamics 365 Portal: Button Filter Criteria for logged user...

    Hello Tim.

    I have implemented a small script that remove the "Deactivate" button for logged in user. I use email address to identify the user. It doesn't work on the Entity Form or List, but on the web page. Remember to add this script on webpages in all languages.

    Paste this code into the "Custom Javascript" section of the web page:

    $('#EntityFormPanel').on("loaded", function () {

     $('.entity-grid.subgrid').on("loaded", function () {

           var email = '{{user.emailaddress1}}';

           $(this).find("td[data-value='"+email+"']").closest("tr").find(".deactivate-link").remove();

       });

    });

    $(document).ready(function () {

     $(".entity-grid.subgrid").trigger("refresh");

    });

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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Abhilash Warrier – Community Spotlight

We are honored to recognize Abhilash Warrier as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

#1
HR-09070029-0 Profile Picture

HR-09070029-0 2

#1
UllrSki Profile Picture

UllrSki 2

#3
ED-30091530-0 Profile Picture

ED-30091530-0 1

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans