locked
ribbon workbench question? RRS feed

  • Question

  • Hello, I'm trying to use ribbon workbench to update the Save button on the ribbon for the incident form. The default behavior of the Save button is that it doesn't submit the form unless a field on the form has changed.

    However, my company's CRM implementation needs to submit changes to an external system when related data on the form changes. For example, a user should be able to add a new note on the incident form, and then click the Save button to send the new note to the external system.

    However, CRM doesn't consider related data updates on the form as a form change.  So I need to implement some type of customization that always triggers the form submit, when the Save button is clicked.

    I opened the incident form through ribbon workbench, and I see that the Save button has a CommandCore of Mscrm.SavePrimary. I've created a new custom command bound to a js function in ribbon workbench. As a basic test, to start, the function code is simply alert('test'). I set my new custom function as the Command for the Save button, but the function doesn't get executed. 

    So my first question is, why doesn't this js function appear to get executed? My second question is, what's the proper implementation for this?  I'm thinking if I can make the form dirty with my custom function, then the default save function will submit the form automatically.  However, is there any way to control if Command or CommandCore gets executed first?  If I can't make my custom command execute before CommandCore, then the form will be stuck with a double postback?

    Also, I'm wondering if this need is a somewhat common use case, so that MS might have built in a configurable setting through the CRM UI to always postback the form on Save?

    Tuesday, November 5, 2013 1:33 AM

All replies

  • Based on your scenario, I would recommend using a workflow to call a workflow assembly or a plug-in that will execute upon save of the entity.  However, you may have already determined that this will not work for your situation.

    To answer your Ribbon Workbench issue, you will need to add your javascript to the Save button's "Action" element.  You need to make sure you have the webresource that contains the JavaScript within the solution used when opening the ribbon workbench.  Make sure you are call the correct name of the javascript function.  I think adding it as the Command or Command Core will prevent the Save itself from working.  I ran into a similar issue today, but was able to overcome it.

    I would willing to help you with this issue tomorrow morning (Thursday).  You can contact me at jyockey@lbmc.com and we can do a JoinMe and phone call.

    Thursday, November 7, 2013 5:43 AM
  • Hi Yockey - In RWB, the Save button does not have an Action element that I'm aware of.  It has a Command input and a CommandCore input.  The CommandCore seems to be the native configured js function, which in the case of my implementation, is Mscrm.SavePrimary.  I set the Command input to a custom action, but it does not seem to get executed when the Save button is clicked.

    Wednesday, November 27, 2013 3:11 AM
  • I came here to post exactly the same question and found that another user had already posted about this too: https://community.dynamics.com/crm/f/117/t/116426.aspx. I've been trying similar things in the past and have had no luck with the Ribbon Workbench. 

    I have implemented similar where I needed a form to always submit a save state regardless of changes to the form or not. If I have your original question correct, then your requirments doesn't really necessitate a workflow and you can do what I did and implement a counter on the page for the OnLoad event, that increments on Form load:

    function counter(){

    //add one to new_field

    }

    This way the form is always in a ready to save data on page Load. However, once the first save has been committed, any further saves will not take place because there is obviously no change to the form. My method to fix that is by implementing an onLoad timer to the page where the field is constantly being changed so as soon as the first save takes place, you can save again. This way there is continuous saving.

    Both methods will need to be hooked on to the onLoad event - they are not clean. I am hoping that the Dev Scott Durow sees this so he can comment. I too would like the feature to be implemented in the Ribbon instead.


    Wednesday, November 27, 2013 8:35 AM
  • Hi,

    You can Customise the command of the Save button if you replace the standard action with your own one, but as you describe CRM will not do a form save unless something has changed, so the only way to force this would be to use setSubmitMode to always http://msdn.microsoft.com/en-us/library/gg334409.aspx#BKMK_setSubmitMode.

    With CRM2013, the save button is hidden by default in favour of a background save - so it may be better to register some custom code on the onsave event (inconjunction with setSubmitMode) rather than customising the ribbon button. http://msdn.microsoft.com/en-us/library/gg334720.aspx#BKMK_addOnSave

    Hope this helps,

    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"

    Friday, November 29, 2013 10:41 AM
    Answerer