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

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Customer experience | Sales, Customer Insights,...
Answered

How does one use a variable in a webapi filter?

(0) ShareShare
ReportReport
Posted on by

Error message: Syntax error at position 22 in 'msdyn_name eq CA-90028'.

Script: 

        if (formContext.getAttribute("shipto_postalcode").getValue() && formContext.getAttribute("shipto_stateorprovince").getValue()) {
            var taxGroupName = formContext.getAttribute("shipto_stateorprovince").getValue()   "-"   formContext.getAttribute("shipto_postalcode").getValue();
            alert(taxGroupName);

            Xrm.WebApi.retrieveMultipleRecords("msdyn_taxgroup", "?$select=msdyn_name&$filter=msdyn_name eq "   taxGroupName).then(

or am I making some simpler syntax error?

TIA

I have the same question (0)
  • Verified answer
    Community Member Profile Picture
    on at

    Try single quotes around the taxGroupName

    Go to:

    -assuming your version is 9.1, change as needed.

    YOURCRMBASEURL.com/.../msdyn_taxgroups eq 'CA-90028'

    What comes back?

  • Community Member Profile Picture
    on at

    Now, unfortunately I have to figure out a way to have it fire before the order save (double saving required.)

  • Community Member Profile Picture
    on at

    So what is needed to happen and why a double save?  Maybe I can help get it down to 1.

  • Community Member Profile Picture
    on at

    I have placed shipto_name/_stateorprovince/_postalcode fields to the address form and added this method to their onChange events.  Of course, add/change addresses run through an mscrm method attached to the lookup address button/dialog.

    I change the address and can see fields change but the method does not fire until I save; and I have no place to script ".fireOnChange()".

    Hence it saves and comes back dirty.

    ps- for all the kids out there: 

    Xrm.WebApi.retrieveMultipleRecords("msdyn_taxgroup", "?$select=msdyn_name&$filter=msdyn_name eq '"   taxGroupName   "'").then(
    

  • Community Member Profile Picture
    on at

    I think there is a way by modifying the ribbon to move the mscrm function from the button to the javascript and replace the command on the button but, I'm hoping there is a more easily maintainable solution.

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

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Women in Power Builds Momentum

Expanding mentorship, skilling, and AI innovation

Congratulations to the July Top 10 Community Leaders

These are the community rock stars!

Leaderboard > Customer experience | Sales, Customer Insights, CRM

#1
11manish Profile Picture

11manish 86 Super User 2026 Season 2

#2
Daniyal Khaleel Profile Picture

Daniyal Khaleel 58 Most Valuable Professional

#3
Muhammad Shahzad Shafique Profile Picture

Muhammad Shahzad Sh... 42 Most Valuable Professional

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans