Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics CRM forum
Unanswered

CRM2011, Dialog: Pass field data to dialog

Posted on by 417

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.
  • bernhards Profile Picture
    bernhards 417 on at
    RE: CRM2011, Dialog: Pass field data to dialog

    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..

  • bernhards Profile Picture
    bernhards 417 on at
    RE: CRM2011, Dialog: Pass field data to dialog

    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
    bernhards 417 on at
    RE: CRM2011, Dialog: Pass field data to dialog

    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....

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: CRM2011, Dialog: Pass field data to dialog

    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
    bernhards 417 on at
    RE: CRM2011, Dialog: Pass field data to dialog

    Unfortunately it's CRM 2011..

  • Indika Abayarathne Profile Picture
    Indika Abayarathne 671 on at
    RE: CRM2011, Dialog: Pass field data to dialog

    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
    bernhards 417 on at
    RE: CRM2011, Dialog: Pass field data to dialog

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

  • David Jennaway Profile Picture
    David Jennaway 14,061 on at
    RE: CRM2011, Dialog: Pass field data to dialog

    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

Helpful resources

Quick Links

Dynamics 365 Community Update – Sep 16th

Welcome to the next edition of the Community Platform Update. This is a weekly…

Announcing Our 2024 Season 2 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 290,349 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 228,212 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,148

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans