Problem displaying alert with custom button RRS feed

  • Question

  • Hi,

    I'm still working in CRM 4 and my issue is as follows :

    I have a custom toolbar button that was added to ISV and when clicked I want to make a copy of an invoice (with products and such).

    So, when I click the button I get the objectID and I pass it to a SOAP message that's going to creat an instance of a "dummy" entity that will allow me to trigger a plugin.

    Now, I'm trying to return a message to the user after the invoice has been created but my only way through server side code in a plugin would be to throw an invalidpluginexec message which of course would revert the process.

    Is there any way to do this? Coming back to JS is impossible from server side.

    Would appreciate if someone could help me.


    Tuesday, December 3, 2013 1:42 PM

All replies

  • Hi ,

    if you open your custom page with modal mode , you can take the unique id after you finish creating the invoice .

    İ'm not sure but this js code will solve your problem.

    var url = '/test.aspx';
    var SelectRecordId= window.showModalDialog(url, null, 'dialogWidth:800px;dialogHeight:600px;resizable:yes');

    if (SelectRecordId) {

    alert('Your Invoice has been created.');

                return true;

    else {
                          return false;

    Tuesday, December 3, 2013 2:32 PM
  • I'm not using a custom page, just a custom button. What I do once I click the button is crate an instance of a mocukp/dummy entity, get the objectID of it and pass it to a sOAP message so I can access server side code in a plugin.
    Tuesday, December 3, 2013 2:45 PM
  • Anyone has a clue?

    Wednesday, December 4, 2013 10:00 AM
  • You can to create custom webservice. Send to service your objectID, create you invoice and return any messages.

    webservice will call after button click

    Any variant

    you add for "dummy" entity new field (exceptionMessage)

    Develop PreCreatePlugin for "dummy" entity Create

    In plugin you create invoice

    If you try exception, you white in exceptionMessage exception or write "OK".

    After create "dummy" entity you analize message field.

    If exceptionMessage== "OK" the you create Invoice

    or you get Exception and you alert(exceptionMessage)

    • Edited by g.Naukovych Wednesday, December 4, 2013 10:43 AM
    Wednesday, December 4, 2013 10:40 AM
  • Thanks for the reply. I see what you mean, the problem is once the service.create for the invoice is called it will in turn fire other custom plugins that run async for the invoice.

    If I throw an exception on the "dummy" entity, odds are that not everything has been processed yet so it will throw an unknown server error.

    Wednesday, December 4, 2013 10:47 AM
  • Async plugins have some timeout.

    You can not get message from async plugins

    But you can update one field of your entity with buttons from async plugins.

    In entity you can create js script who will retrieve field value by SOAP query.

    Js script will call every one second and if field have value, script show this value on screen and stoped.

    It's not good solution, because async timeout can be much.

    I think you don't have any way

    Wednesday, December 4, 2013 11:51 AM
  • Well it isn't the dummy entity that is asynchronous. I know I can't throw InvalidPluginExecutionException from async plugins :) .

    The problem is once the invoice gets created it runs a pattern of updates that do trigger asynchronous plugins.

    But anyway, how would I do that through JS with SOAP after going server side and most of all how would I trigger that field value again so it wouldn't trigger the message the next time it loads?

    Can you help me with some generic code please?



    Wednesday, December 4, 2013 12:03 PM
  • //Last step AsyncPlugin it's update field new_exceptionmessage
    var intervalID = setInterval(
    		var new_exceptionmessageValue = '';
    		In this block you retrieve new_exceptionmessage
    		new_exceptionmessage it's field on your entity
    		if(new_exceptionmessageValue != null && new_exceptionmessageValue  != '')
    			alert(new_exceptionmessageValue );
    I write this code without testing, but I think that you understand idea
    Thursday, December 5, 2013 11:44 AM