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

Community site session details

Session Id :
Microsoft Dynamics 365 | Integration, Dataverse...
Unanswered

Plugin help needed updating some fetch

(0) ShareShare
ReportReport
Posted on by 270

I have a plugin, in which I am using a fetch query, it worked fine.

However the scope has changed and in the fetch statement, i need to update the following line, to retrieve the record where the "accountuniquenumber"'s last 7 digits match not the full value.

I know i need to update the following to sections but not sure to what, can i retrieve just the last 7 digits and then make the condition so it ends in?

  1. if (Target.Attributes.Contains("cr011_accountuniquenumber"))
    UniqueNumber = Target.Attributes["cr011_accountuniquenumber".ToString();
     
  2. <condition attribute='cr011_accountuniquenumber' operator='like' value='%{2}' />



   

                Entity Target = context.InputParameters["Target"] as Entity;
                try
                {
                    string AccountName = "", UniqueNumber = "", ZipCode = "";
                    if (Target.Attributes.Contains("cr011_accountname"))
                        AccountName = Target.Attributes["cr011_accountname"].ToString();
                    if (Target.Attributes.Contains("cr011_accountuniquenumber"))
                        UniqueNumber = Target.Attributes["cr011_accountuniquenumber"].ToString();
                    if (Target.Attributes.Contains("cr011_address1zippostalcode"))
                        ZipCode = Target.Attributes["cr011_address1zippostalcode"].ToString();
                    #region FetchAccounts
                    string AccountsFetchQuery =
                            @"
                                      
                                        
                                        >
                                        
                                        
                                        
                                        
                                          
                                          
                                          
                                        
                                        
                                          
                                        
                                      
                                    ";

I have the same question (0)
  • Federico Pelliccia Profile Picture
    75 on at
    RE: Plugin help needed updating some fetch

    You could try something like this:

    UniqueNumber = Target.Attributes["cr011_accountuniquenumber"].ToString();

    UniqueNumberSubStr = UniqueNumber .Substring(UniqueNumber .Length - 7);

    And yes, with like=%{UniqueNumberSubStr } (I am using $"" annotation) you should compare just the last 7 characters

  • GRedhead Profile Picture
    270 on at
    RE: Plugin help needed updating some fetch

    Hi, thanks for the reply, however when i try and update my code to your suggestion i get the following error when building the solution, it's probably me though, can you point out where I am messing up, please?

    pastedimage1633952545787v1.png

  • GRedhead Profile Picture
    270 on at
    RE: Plugin help needed updating some fetch

    Hi, i'm still getting this error, any suggestions are most welcome.

  • Federico Pelliccia Profile Picture
    75 on at
    RE: Plugin help needed updating some fetch

    You must write string before UniqueNumber. It is a variable, so you must specify the type

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…

Abhilash Warrier – Community Spotlight

We are honored to recognize Abhilash Warrier as our Community Spotlight honoree for…

Leaderboard > Microsoft Dynamics 365 | Integration, Dataverse, and general topics

#1
Sahan Hasitha Profile Picture

Sahan Hasitha 284

#2
Sohaib Cheema Profile Picture

Sohaib Cheema 104 User Group Leader

#3
CA Neeraj Kumar Profile Picture

CA Neeraj Kumar 77

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans