Skip to main content

Notifications

Announcements

No record found.

Customer experience | Sales, Customer Insights,...
Unanswered

CRM Plugin - Check inventory data

Posted on by 25

Hello,

I am working on a plugin for CRM on-prem v8. 

The plugin should be checking the quantities of the products which are added via another form.

So there is an Order form and the products are listed in another form, let's call it Order Lines. Order form does not have a direct field for use of EntityReference, so I am using the QueryExpression with the Order forms GUID, to get the Order Lines. In the Order Lines form, I have products with quantities and I need to check those quantities in another form that contains aggregated quantities of each product. 

I am calling this plugin on the "Update" message, PreOperation, from the Order form.

What is the best way to do it? Can I use the results from the QueryExpression together with the EntityReference?

Columnset columns:

{[sc_product, Microsoft.Xrm.Sdk.EntityReference}

{[sc_location, Microsoft.Xrm.Sdk.EntityReference}

Here is the code so far:

QueryExpression orderlineQuery = new QueryExpression { EntityName = "sc_salesorderline", ColumnSet = new ColumnSet(new string[] {"sc_product","sc_location","sc_quantity"}) };
                    orderlineQuery.Criteria = new FilterExpression();
                    orderlineQuery.Criteria.AddCondition("sc_salesorderno", ConditionOperator.Equal, new Guid(target.Attributes["sc_salesorderid"].ToString()));
                    orderlineQuery.Criteria.AddCondition("statuscode", ConditionOperator.Equal, "1");
                    var result = service.RetrieveMultiple(orderlineQuery);
                    trace.Trace("REsult "   result.ToString());
                    if (result.Entities.Count > 0)
                    {
                        foreach(var results in result.Entities)
                        {

                        }
                    }

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,280 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,214 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans