Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics CRM (Archived)

Error - Post retrieve savedquery

Posted on by 1,145

Hi,

I have made a synchronous plugin registered on Post retrieve of savedquery.

So I want to modify the fetchxml and the layoutxml of a view.

The update of the fetchxml works well, not the layout.

the new layout throw an error:

4628.Capture.PNG

Here is the code below:

var output = esp.GetOutputParameter<Entity>("BusinessEntity");
 QueryExpression qenew = new QueryExpression("sqli_opportunityroadmap");
            qenew.ColumnSet.AddColumns("sqli_annee");
            qenew.LinkEntities.Add(new LinkEntity("sqli_opportunityroadmap", "opportunity", "sqli_opportunitid", "opportunityid", JoinOperator.LeftOuter));
            qenew.LinkEntities[0].Columns.AddColumns("sqli_num_chrono", "parentaccountid", "sqli_roadmap");
            qenew.LinkEntities[0].EntityAlias = "roadmap";
            qenew.LinkEntities[0].LinkCriteria.Filters.Add(
                   new FilterExpression()
                   {
                       FilterOperator = LogicalOperator.And,
                       Conditions =
                       {
                           new ConditionExpression("estimatedclosedate", ConditionOperator.NextXMonths, 3),
                       }
                   }
               );
            QueryExpressionToFetchXmlRequest req = new QueryExpressionToFetchXmlRequest();
            req.Query = qenew;
            QueryExpressionToFetchXmlResponse resp = (QueryExpressionToFetchXmlResponse)AdminService.Execute(req);

            string myfetch = resp.FetchXml;
 System.String layout = @"< grid name ='resultset' icon='1' preview='1' select='1' jump='sqli_name' object='10074'>
                          < row id ='sqli_opportunityroadmapid' name='result'>                              
                                 </row>
                                </ grid > ";
            output["layoutxml"] = layout; // if I comment this line, the view is correctly displayed with default layout.
            output["fetchxml"] = myfetch;


Thank you.

Saad

*This post is locked for comments

  • Suggested answer
    Alex Fun Wei Jie Profile Picture
    Alex Fun Wei Jie 33,626 on at
    RE: Error - Post retrieve savedquery

    Hi,

    i think the real problem is

    @"< grid name ='resultset' icon='1' preview='1' select='1' jump='sqli_name' object='10074'>

                             < row id ='sqli_opportunityroadmapid' name='result'>                              

                                    </row>

                                   </ grid > ";

    there is a space between your </grid> .

    After corrected, it should be working too.

     @"<grid name ='resultset' icon='1' preview='1' select='1' jump='sqli_name' object='10074'>
                              <row id ='sqli_opportunityroadmapid' name='result'>                              
                                     </row>
                                    </grid > ";

    haha

  • Verified answer
    saadzag Profile Picture
    saadzag 1,145 on at
    RE: Error - Post retrieve savedquery

    Hello,

    I found it, the problem came from the quotes.

    It shoud be double quotes, so here is the new layoutxml:

     @"<grid name =""resultset"" object=""10074"" icon=""1"" preview=""1"" select=""1"" jump=""sqli_name"" >
                              <row id =""sqli_opportunityroadmapid"" name=""result"">    
                                <cell name=""sqli_opportunitid"" width=""125"" />
                                     </row>
                                    </grid> ";


  • saadzag Profile Picture
    saadzag 1,145 on at
    RE: Error - Post retrieve savedquery

    Hi,

    In the begining there was 3 columns(cells), and  it doesn't work. Then I tried by deleting cells.

  • Alex Fun Wei Jie Profile Picture
    Alex Fun Wei Jie 33,626 on at
    RE: Error - Post retrieve savedquery

    Hi,

    from the code, the layout is missing the cellname, try to give some field into it.

  • saadzag Profile Picture
    saadzag 1,145 on at
    RE: Error - Post retrieve savedquery

    Hi,

    What do you mean by primary Key? do you mean in your example accountid?

    Regards,

    Saad

  • Suggested answer
    Alex Fun Wei Jie Profile Picture
    Alex Fun Wei Jie 33,626 on at
    RE: Error - Post retrieve savedquery

    Hi,

    i copied out from my environment.

    7607.18.png

    Sample

    <grid name="resultset" object="1" jump="name" select="1" icon="1" preview="1">

    <row name="result" id="accountid"><cell name="name" width="300" />

    <cell name="primarycontactid" width="150" /><cell name="telephone1" width="100" />

    </row>

    </grid>

    you can try to insert the primary key field into the cell

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

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,269 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,198 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans