Question

I created a dialog for getting data from the user. I want to access the user's responses from a plugin. I get the processsession entity in my plugin but there seems to be only metadata attached to it.

How can I get the user's responses from within the Plugin? Please note that I am using CRM online.

This link describes how to obtain the responses in the on-premise version. I cannot use that if I understood that correctly.

This article shows how to access comments from the dialogs but not the actual responses.

Here is what I did so far. The following code leads to the following output:

// we are in the plugin's execute method here
if (context.PostEntityImages.Contains("PostImage")
                        && context.PostEntityImages["PostImage"].Attributes.Contains("comments"))
                    {
                        var postImage = (Entity)context.PostEntityImages["PostImage"];
                        if (postImage.Attributes.Contains("regardingobjectid"))
                        {
                            EntityReference regardingEntity = (EntityReference)postImage.Attributes["regardingobjectid"];
                            if (regardingEntity.LogicalName.Equals("contact"))
                            {
                                var DialogComments = (string)postImage.Attributes["comments"];

                                foreach (object o in postImage.Attributes)
                                {
                                    trace(o.ToString());
                                }
}}}

The output is:

modifiedon, 9/10/2013 11:08:57 AM]
[statecode, Microsoft.Xrm.Sdk.OptionSetValue]
[regardingobjectid, Microsoft.Xrm.Sdk.EntityReference]
[startedby, Microsoft.Xrm.Sdk.EntityReference]
[createdon, 9/10/2013 11:08:47 AM]
[completedon, 9/10/2013 11:08:57 AM]
[completedby, Microsoft.Xrm.Sdk.EntityReference]
[processsessionid, ca15ec57-091a-e311-a88f-ac162dbe3218]
[ownerid, Microsoft.Xrm.Sdk.EntityReference]
[name, DialogSessionTest]
[statuscode, Microsoft.Xrm.Sdk.OptionSetValue]
[comments, eeeeeeeeeeeee]
[executedon, 9/10/2013 11:08:47 AM]
[modifiedby, Microsoft.Xrm.Sdk.EntityReference]
[owningbusinessunit, Microsoft.Xrm.Sdk.EntityReference]
[createdby, Microsoft.Xrm.Sdk.EntityReference]
[startedon, 9/10/2013 11:08:47 AM]
[processid, Microsoft.Xrm.Sdk.EntityReference]
[owninguser, Microsoft.Xrm.Sdk.EntityReference

I do not see any field to access the user's responses here. How can I access them?

Edit: I read here that I can use FetchXML to query the database in CRM online. Can I query views with that, too, or is it only for querying entities?

Thanks in advance and Cheers,
Arne

Was it helpful?

Solution

Here is the way I've used in recent project:

  1. Create new entity in which you will write all responces from dialog (create approprite fields, e.g. "Name", "Surname").
  2. Create dialog for interaction. Gather all data and write it in new entity you created in previous step.
  3. Register new plug-in on create on entity from p.1. Do all processing in this plugin.

You can write all data in this entity including reference on record that initiate dialog (e.g. if dialog is for Contact: in "Look for:" select Contact in first field and Contact in second field - this will write EntityReference in the Look Up field).

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top