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

Notifications

Announcements

No record found.

Community site session details

Community site session details

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

Dynamics 365 - Issue with Jscript/fetchXML: linking entities for filtering a field

(0) ShareShare
ReportReport
Posted on by 2

Hello everyone,

The filter I want to create is as follows: I want to filter a field (uneeti_agreementinvoiceproduct) located in my table (msdyn_customerasset). The filter must meet the following conditions: firstly, the customer of the contract must be equal to the asset account. In my fetchXML query from my table (msdyn_agreementinvoiceproduct), I will retrieve the linked contract table (msdyn_agreement) and the field (msdyn_serviceaccount) for comparison. Secondly, I want to display only the products that are already associated with the contract asset. Therefore, I retrieve my product field from my table (msdyn_customerasset) and fetch the (msdyn_product) from my table (msdyn_agreementinvoiceproduct). Here is my retrieval query, along with the error that is occurring. I don't understand this error because the specified field is not associated with the indicated table.

Can someone help me resolve this issue ?

JS : 

    function filterProductContratFS(context) {

    var formContext = context.getFormContext();

    var fieldRecipientCall = formContext.getAttribute(/msdyn_account/).getValue();
    var fieldRecipientCall2 = formContext.getAttribute(/msdyn_product/).getValue();

    if (fieldRecipientCall && fieldRecipientCall2) {
    var accountId = fieldRecipientCall[0].id;
    var productId = fieldRecipientCall2[0].id;

    console.log(accountId);
    console.log(productId);

 

    var fetchXML =
    /<fetch>/ +
    /<entity name='msdyn_agreementinvoiceproduct'>/ +
    /<link-entity name='msdyn_agreement' from='msdyn_agreementid' to='msdyn_agreement'>/ +
    /<filter>/ +
    /<condition attribute='msdyn_serviceaccount' operator='eq' value='/ + accountId + /' uitype='account'/>/ +
    /</filter>/ +
    /</link-entity>/ +
    /<link-entity name='msdyn_customerasset' from='msdyn_customerassetid' to='msdyn_agreementinvoiceproductid'>/ +
    /<filter>/ +
    /<condition attribute='msdyn_product' operator='eq' value='/ + productId + /' />/ +
    /</filter>/ +
    /</link-entity>/ +
    /</entity>/ +
    /</fetch>/;

    var agreementInvoiceProductControl = formContext.getControl(/uneeti_agreementinvoiceproduct/);
    agreementInvoiceProductControl.addPreSearch(function () {
    agreementInvoiceProductControl.addCustomFilter(fetchXML);
    });

    } else {
    return;
    }}

Error : 

//////////

I have the same question (0)
  • Community member Profile Picture
    2 on at
    The problem is solved. Here is a useful link for those who encounter the same problem.
     

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…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

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

#1
Martin Dráb Profile Picture

Martin Dráb 51 Most Valuable Professional

#2
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 38 Super User 2025 Season 2

#3
#ManoVerse Profile Picture

#ManoVerse 31

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans