0

I need to make a HTML web-resource where I can add a button on it. The button should open a Dialog, I have already made the HTML page and add it to the web-resources in CRM11. But now I need to pass parameters on the click event so we can call the dialog. The dialog gets triggered by the java script code in it. I don't know how to pass these parameters from HTML to javascript.

I need to add these parameters to the javascript code:

HTML

<HTML><HEAD><TITLE>Untitled Page</TITLE>
<META charset=utf-8></HEAD>
<BODY contentEditable=true>
<SCRIPT src="ClientGlobalContext.js.aspx"></SCRIPT>

<SCRIPT type=text/javascript src="rd_/javascripts/LaunchModalDialog.js"></SCRIPT>

<STYLE type=text/css>
    #Button1
    {
        width: 200px;
    }
</STYLE>

<P><INPUT id=Button1 onclick=LaunchModalDialog() value=button type=button>       </P></BODY>    </HTML>

Javascript

function LaunchModalDialog(dialogId, typeName, recordId)
{
var serverUrl = Xrm.Page.context.getServerUrl();
recordId = recordId.replace("{", "");
recordId = recordId.replace("}", "");

dialogId = dialogId.replace("{", "");
dialogId = dialogId.replace("}", "");

// Load Modal
var serverUri = serverUrl + '/cs/dialog/rundialog.aspx';
var myPath = serverUri + '?DialogId=%7b' + dialogId.toUpperCase()  +'%7d&EntityName=' + typeName+'&ObjectId=%7b' +recordId+'%7d';

// First item from selected record
window.showModalDialog(myPath);

// Reload form
window.location.reload(true);
} 
0

1 Answer 1

1

For that you write the values for the parameter in the HTML as

onclick="LaunchModalDialog(firstParam, secondParam, thirdParam)"

This way, when it would trigger, it would pass on the values.

It can be anything, integer, string etc. What so ever you want to send to the function.

Also, please note that the values for attributes must be qouted

<input id="Button1" 
 onclick="LaunchModalDialog(firstParam, secondParam, thirdParam)" 
 value="button" type="button" /> 

You have only 3 parameters, that's why I have included only 3, you can add more or less depending on the nature and type of function you're using.

Sign up to request clarification or add additional context in comments.

2 Comments

When i pass these parameters, i get a error in the script :s it says syntax error, and it changes my script to something different.
Sorry my fault, i used double quotes for the parameter, so this works now.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.