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

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

How to pass GUID dynamically into fetchXML?

(1) ShareShare
ReportReport
Posted on by

Hello,

I am trying to create a workflow that generates an email that includes a table with results of a specific record.

We have a custom entity called "Business Diagnostic" which has a child entity of "Business Diagnostic Contents". When a flag is triggered on the "Business Diagnostic" entity, I want the workflow to pull data from both the "Business Diagnostic" and "Business Diagnostic Contents" for the Account that is related to the diagnostic. (There is an account field on both related entities). 

I have created the workflow which uses 'Kaskela's Workflow Elements:Query - Get Results' which I have passed in some fetchXML to retrieve the data I want to put into a table.

When I hard code a person's GUID into the condition value - the workflow works. However, we want to pass in the GUID for the Account that is related to the specific "Business Diagnostic". After reading a lot of suggestions on the forum, we have tried a number of ways to get the GUID which haven't worked for us, such as:

"#name#"
"+name+"
'"+name+"'
{"+name+"}

The fetchXML is as followed:

<fetch version="1.0" output-format="xml-platform" mapping="logical" distinct="false">
  <entity name="new_businessdiagcontent">
    <attribute name="new_priority" />
    <attribute name="new_discipline" />
    <attribute name="new_businessdiagcontentid" />
    <attribute name="new_primarysupportoffer" />
    <order attribute="new_discipline" descending="false" />
	<filter type="and">
          <condition attribute="new_account" operator="eq" value="#accountid#" />
	</filter>
    <link-entity name="new_supportoffer" from="new_supportofferid" to="new_primarysupportoffer" visible="false" link-type="outer" alias="a_299baed67641e811a96a000d3ab5cc4c">
      <attribute name="new_whatdoesitdo" />
      <attribute name="new_webaddress" />
      <attribute name="new_telnumber" />
      <attribute name="new_suppliername" />
      <attribute name="new_phone" />
      <attribute name="new_howaccessed" />
      <attribute name="new_email" />
      <attribute name="new_contactrole" />
      <attribute name="new_contactname" />
      <attribute name="new_benefittome" />
    </link-entity>
    <link-entity name="new_businessdiagnostic" from="new_businessdiagnosticid" to="new_bdiagnostic2contentid" link-type="inner" alias="a_9a1fb6a10126e71180f95065f38b15b1">
      <attribute name="new_businessdiagnostictitle" />
      <attribute name="new_accounttodiagid" />
    </link-entity>
  </entity>
</fetch>

The main error we seem to be getting is a Plug In Error (xxxx-xxxxxx) looking for 32 GUID... so we know that the error lies within pointing to the right GUID dynamically. 

Any suggestions would be much appreciated! 

Thanks!! 

*This post is locked for comments

I have the same question (0)
  • Suggested answer
    gdas Profile Picture
    50,091 Moderator on at

    Hello,

    Try to write like this  - declare the Guid variable first and assigned first .

                string fetchXml = string.Format(@"<fetch version = '1.0' output - format = 'xml-platform' mapping = 'logical' distinct = 'false' >" +         
               "<entity name = 'new_businessdiagcontent' >" +          
                  "<attribute name = 'new_priority' />" +           
                   "<attribute name = 'new_discipline' />" +            
                    "<attribute name = 'new_businessdiagcontentid' />" +             
                     "<attribute name = 'new_primarysupportoffer' />" +              
                      "<order attribute = 'new_discipline' descending = 'false' />" +                 
                         "<filter type = 'and' >" +                  
                                "<condition attribute = 'new_account' operator= 'eq' value = '"+ accountid +"' />" +                      
                              "</filter>" +                      
                              "<link - entity name = 'new_supportoffer' from = 'new_supportofferid' to = 'new_primarysupportoffer' visible = 'false' link - type = 'outer' alias = '"+ GuidVariable1 +"' >" +
                                         
                                               "<attribute name = 'new_whatdoesitdo' />" +                                      
                                                "<attribute name = 'new_webaddress' />" +                                       
                                                 "<attribute name = 'new_telnumber' />" +                                        
                                                  "<attribute name = 'new_suppliername' />" +                                         
                                                   "<attribute name = 'new_phone' />" +                                          
                                                    "<attribute name = 'new_howaccessed' />" +                                           
                                                     "<attribute name = 'new_email' />" +                                            
                                                      "<attribute name = 'new_contactrole' />" +                                             
                                                       "<attribute name = 'new_contactname' />" +                                              
                                                        "<attribute name = 'new_benefittome' />" +                                               
                                                       "</link - entity >" +                                               
                                                       "<link - entity name = 'new_businessdiagnostic' from = 'new_businessdiagnosticid' to = 'new_bdiagnostic2contentid' link - type = 'inner' alias = '"+ GuidVariable2 + "' >" +                                                            
                                                                      "<attribute name = 'new_businessdiagnostictitle' />" +                                                             
                                                                       "<attribute name = 'new_accounttodiagid' />" +                                                              
                                                                      "</link - entity >" +                                                              
                                                                    "</entity >" +
                                                                  "</fetch >");
    
                EntityCollection resultCustEqup = service.RetrieveMultiple(new FetchExpression(fetchXml));


  • Suggested answer
    Mahendar Pal Profile Picture
    45,095 on at

    Hello,

    You can write your fetchxml under string variable something like this

    string FetchXML="<fetch version='1.0' output-format='xml-platform' mapping='logical' distinct='false'>";
    FetchXML+="<entity name='new_businessdiagcontent'>";
    FetchXML+="<attribute name='new_priority' /><attribute name='new_discipline' />"
    FetchXML+="<attribute name='new_businessdiagcontentid' /><attribute name='new_primarysupportoffer' />"
    FetchXML+="<order attribute='new_discipline' descending='false' /><filter type='and'>";
    FetchXML+="<condition attribute='new_account' operator='eq' value="+accountid+"/>";
    
    

    Also you should use some name for all the alias in your query for example like below

    <link-entity name='new_businessdiagnostic' from='new_businessdiagnosticid' to='new_bdiagnostic2contentid' link-type='inner' alias='businessdiagnosticentity'>

  • TSP Profile Picture
    10 on at

    Hi @Katie110596 Did you ever find a solution, I have the same problem, I need to set the GUID ID dynamically in the Workflow

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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

#1
SA-08121319-0 Profile Picture

SA-08121319-0 4

#1
Calum MacFarlane Profile Picture

Calum MacFarlane 4

#3
Alex Fun Wei Jie Profile Picture

Alex Fun Wei Jie 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans