locked
Accessing Custom Entity Field Value from outside the scope of Current form RRS feed

  • Question

  • I have a scenario as following:

    1. I have a custom ribbon button displayed on the "dashboards" ribbon
    2. On-clicking the ribbon button an external web service is invoked & a response is received
    3. The response could be accepted or rejected (Simple Text Response)
    4. If the response is "Accepted" I would like to change the custom button text

    ------------------------------------------------------------------------------------------------------


    • I have been told to make a custom entity with a custom field
    • Then I am told to store the response in that custom field
    • Then I am told to read that custom entity filed value
    • Then I am told to change the text of button or enable/disable the button
    • I am asked to use the "ClientGlobalContext.js.aspx"

    Can someone guide me how to use this and if there is any other way of achieving the task? I am using

    "Ribbon Workbench" for customizing the ribbon.


    • Edited by Absaar Tuesday, October 1, 2013 6:14 AM More Clear
    Tuesday, October 1, 2013 6:13 AM

Answers

  • Hi Absaar,

    There is no supported way of changing the label on a button - but what you can do is add two buttons - one that will be the first one displayed, and the second will be displayed after the first is clicked. We call the webservice using the 'CommandPattern' :

    1. Add a custom attribtue to your entity called 'new_command' (or something)

    2. Add a button that has a command that calls a javascript webresource function called 'call_service' 

    3. Add a Display Rule to button 1 with a Value Rule (Field='new_command', Value='Accepted', Invert Result=true)

    4. Add a 2nd button that has a command with a Display Rule that contains a similar Value Rule to Button 1, but with Invert Result = false.

    5. In the 'call_service' javascript, set the new_command field to 'Invoke' (or something). This is just a flag that will be picked up by a plugin. Then call Xrm.Page.data.entity.save()

    6. Create a plugin using the Developer Toolkit (http://msdn.microsoft.com/en-us/library/hh372957.aspx) that has  step registered on update of your entity

    7. In the plugin , check for the new_command attribute changing to 'Invoke' then call your custom webservice.

    8. Update the target entity new_command to be the result

    9. When the form is refreshed, if the value is 'Accepted' then your 2nd ribbon button will be displayed.

    hth,

    Scott



    Scott Durow
    Blog www.develop1.net    Follow Me
    Rockstar365
    If this post answers your question, please click "Mark As Answer" on the post and "Mark as Helpful"

    Tuesday, October 1, 2013 8:25 AM
    Answerer