Skip to main content

Notifications

Announcements

No record found.

Dynamics 365 general forum
Unanswered

Plugin help needed updating some fetch

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 =
                            @"
                                      
                                        
                                        >
                                        
                                        
                                        
                                        
                                          
                                          
                                          
                                        
                                        
                                          
                                        
                                      
                                    ";

  • RE: Plugin help needed updating some fetch

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

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

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

  • GRedhead Profile Picture
    GRedhead 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

  • 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

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

Anton Venter – Community Spotlight

Kudos to our October Community Star of the month!

Announcing Our 2024 Season 2 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Dynamics 365 Community Newsletter - September 2024

Check out the latest community news

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 290,537 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 228,520 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,148

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans