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

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

CRM2011, Dialog: Pass field data to dialog

(0) ShareShare
ReportReport
Posted on by 423

How is it possible to pass the already entered and saved values from a form to a dialog?

Entity: Mail

Field: Account

Value: Test Company

If the user opens the dialog. The Dialog box "Account" should already filled out with "Test company" from the form.

This is the JS opens the dialog with a button:

var popup;
var detailsWindowTimer;
// Parameters: DialogGUID, PrimaryEntityTypeName, PrimaryItemIds, Bool 
function LaunchModalDialog(dialogID, typeName, recordId, refresh) {
   var url = window.location.protocol + "//" + window.location.host;
   if (window.location.href.indexOf(Xrm.Page.context.getOrgUniqueName()) > 0) {
       url = url + "/" + Xrm.Page.context.getOrgUniqueName();
   }
   url = url + '/cs/dialog/rundialog.aspx';
   popup = window.open(url + '?DialogId=' + dialogID + '&EntityName=' + typeName + '&ObjectId=' + recordId, "Dialog", "status=0,toolbar=0,scrollbars=0, resizable=1");
   if (refresh != null && refresh == true) {
       detailsWindowTimer = setInterval("WatchDetailsWindowForClose()", 600); //Poll
   }
}
function WatchDetailsWindowForClose() {
  if (!popup || popup.closed) {

      clearInterval(detailsWindowTimer); //stop the timer
      if(Xrm.Page.data.entity.getIsDirty() == true) {
          Xrm.Page.data.entity.save();
      } else {
           window.location.reload(true);
      }
  }
}
Is it possible to pass this as argument? I also tried to realise it with the dialog arguments/parameters but wasn't able to do that...
Note: The field in the dialog is a lookup field and needs to be that.

*This post is locked for comments

  • David Jennaway Profile Picture
    14,065 on at

    If the value has already been saved to CRM, you should be able to use a Query CRM Data step to read this value into a variable, then use it later in the dialog

  • bernhards Profile Picture
    423 on at

    Would this be a CRM step in the Dialog creation or a Jscript?

  • Indika Abayarathne Profile Picture
    671 on at

    In Dynamics 365/CRM processes, One of the features is to query data from CRM. You can use that feature to get the fields value you want in the Process.

    crmfortress.com

  • bernhards Profile Picture
    423 on at

    Unfortunately it's CRM 2011..

  • Community Member Profile Picture
    on at

    Hi!

    Not sure it will work for lookups. But it worked for me for numeric values.

    Create and Setup dialog variable with your lookup value from entity form.

    In dialog promt and response setup you field default value with that variable.

    Only child dialogs can accept input parameters.

    Dynamica Labs http://dynamicalabs.com/

    Disclaimer:

    Any post on this page provided "as is" without warranty of any kind and is for educational and information purposes only. We disclaim any liability arising from any reliance placed on any post.

  • bernhards Profile Picture
    423 on at

    Thanks for your answer. Normally I would agree but the problem is the reaction/prompt dialog. You can't set the fields default value if you define it as a lookup:

    0066.crm2.png

    For example "date and time":

    0066.crm2.png

    You can see there is a field called "Standardwert" simply means default value. This field is what I miss in the lookup. A field where I can define the default value of a local process value....

  • bernhards Profile Picture
    423 on at

    Hello all,

    I tried to solve this problem with the JS code but stucking at setting the value in the new opened dialog window (please look at LINE 35: //HERE IS THE PROBLEM):

    var popup;
    var detailsWindowTimer;
    // Parameters: DialogGUID, PrimaryEntityTypeName, PrimaryItemIds, Bool 
    function LaunchModalDialog(dialogID, typeName, recordId, refresh) {
        //Get the GUID of the field "to"
        var accountGUID = "";
    
        try {
            var savedAccountValue = Xrm.Page.getAttribute("to");
            var accountGUID = savedAccountValue.getValue()[0].id;
            console.log(accountGUID);
    
        } catch(err) {
            console.log("ERROR: " + err + accountGUID);
        }
    
        //Concate for Dialog URL
        var url = window.location.protocol + "//" + window.location.host;
        if (window.location.href.indexOf(Xrm.Page.context.getOrgUniqueName()) > 0) {
        url = url + "/" + Xrm.Page.context.getOrgUniqueName();
        }
    
        //Open the Dialog
        url = url + '/cs/dialog/rundialog.aspx';
        popup = window.open(url + '?DialogId=' + dialogID + '&EntityName=' + typeName + '&ObjectId=' + recordId, "Dialog", "status=0,toolbar=0,scrollbars=0, resizable=1");
        
        //Check if the window is closed. Save the current form on dialog close
        if (refresh != null && refresh == true) {
            detailsWindowTimer = setInterval("WatchDetailsWindowForClose()", 600); //Poll
        }
    
        //Set the field "To" in the Dialog like the value of the form
        if(accountGUID != ""){
            try{
                //HERE IS THE PROBLEM
                popup.document.getElementById('InteractionStep27_prompt').value = accountGUID;
            } catch(e){
                alert("ERROR: Can not set value of field: " + e);
            }
        }
    
    }
    
    //Save when the Dialog is closed
    function WatchDetailsWindowForClose() {
    if (!popup || popup.closed) {
        clearInterval(detailsWindowTimer); //stop the timer
            if(Xrm.Page.data.entity.getIsDirty() == true) {
                Xrm.Page.data.entity.save();
            } else {
                window.location.reload(true);
            }
        }
    }


    How can I set the value in a dialog lookup field?

  • bernhards Profile Picture
    423 on at

    Ok the problem is not setting the field. It is to get the ID of the field which is created in a dialog. I also exported the dialog as solution and took a look

    <mcwa:Interaction AttributeDelimiter="{x:Null}" DefaultResponseValue="{x:Null}" DynamicQueryAttributeList="{x:Null}" DynamicQueryResult="{x:Null}" QueryEntityName="{x:Null}" QueryVariableName="{x:Null}" StaticResponseValues="{x:Null}" DisplayName="InteractionStep27: Customer" HintText="[InteractionStep27_2]" IsResponseMetadataBound="True" LogResponse="True" PromptText="[InteractionStep27_1]" ResponseContainerType="7" ResponseMetadataSource="<MetadataSource><EntityName>email</EntityName><AttributeName>regardingobjectid</AttributeName></MetadataSource>" ResponseMetadataType="5" UserResponse="[InteractionStep27_interactionResponseValue]" />

    Is "InteractionStep27" the ID of this field? I tried to get the field to find that out with

    Xrm.Page.data.entity.attributes.get("InteractionStep27");

    but it tells me it is not defined..

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

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Women in Power Builds Momentum

Expanding mentorship, skilling, and AI innovation

Congratulations to the August Top 10 Community Leaders

These are the community rock stars!

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

#1
ScottDurow Profile Picture

ScottDurow 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans