0

I am constructing dynamic custom look in LWC , and I want to display the name of look up automatically if the field is ID field. In the dynamic query I can just able to pass only the ID of look up field and there will be n number of look up field ids. Here is my dynamic Query

Select Id,AcctSeed__Vendor__c,AcctSeed__Contact__c,AcctSeed__Accounting_Period__c,
AcctSeed__Date__c,AcctSeed__Due_Date__c,AcctSeed__Payee_Reference__c,Name,AcctSeed__Status__c, 
(select id ,AcctSeed__Product__c,AcctSeed__Quantity__c,AcctSeed__Unit_Cost__c,AcctSeed__Sub_Total__c,
AcctSeed__Tax_Rate__c,AcctSeed__Tax_Amount__c,AcctSeed__Amount__c,AcctSeed__Expense_GL_Account__c,AcctSeed__Project__c,
AcctSeed__Project_Task__c,AcctSeed__GL_Account_Variable_1__c,AcctSeed__GL_Account_Variable_2__c from AcctSeed__Account_Payable__c

and the above query will give out put like this

[
  {
    "AcctSeed__Account_Payable__c": "a09K000000GggQsIAJ",
    "Id": "a08K000000GWyEkIAL",
    "AcctSeed__Product__c": "01tK0000007HuZ8IAK",
    "AcctSeed__Quantity__c": 3,
    "AcctSeed__Unit_Cost__c": 5,
    "AcctSeed__Sub_Total__c": 15,
    "AcctSeed__Tax_Rate__c": 0,
    "AcctSeed__Tax_Amount__c": 0,
    "AcctSeed__Amount__c": 15,
    "AcctSeed__Expense_GL_Account__c": "a0kK000000ArWx4IAF",
    "AcctSeed__Project__c": "a0vK0000009vjBQIAY",
    "AcctSeed__Project_Task__c": "a0uK0000009Qb7wIAC",
    "AcctSeed__GL_Account_Variable_1__c": "a0DK000000MHgHVMA1",
    "AcctSeed__GL_Account_Variable_2__c": "a0DK000000MHgHaMAL"
  },
  {
    "AcctSeed__Account_Payable__c": "a09K000000GggQsIAJ",
    "Id": "a08K000000GWyElIAL",
    "AcctSeed__Product__c": "01tK0000007HuZSIA0",
    "AcctSeed__Quantity__c": 4,
    "AcctSeed__Unit_Cost__c": 5,
    "AcctSeed__Sub_Total__c": 20,
    "AcctSeed__Tax_Rate__c": 0,
    "AcctSeed__Tax_Amount__c": 0,
    "AcctSeed__Amount__c": 20,
    "AcctSeed__Expense_GL_Account__c": "a0kK000000ArWx4IAF",
    "AcctSeed__Project__c": "a0vK0000009vjBQIAY",
    "AcctSeed__Project_Task__c": "a0uK0000009Qb7wIAC",
    "AcctSeed__GL_Account_Variable_1__c": "a0DK000000MHgHVMA1",
    "AcctSeed__GL_Account_Variable_2__c": "a0DK000000MHgHaMAL"
  }
]

In the above is there a way to identify a look up field and get the name of it automatically like for eg

"AcctSeed__Product__c": "01tK0000007HuZ8IAK",// Need name automatically

This is not going to be static query . If it is static then I can include

AcctSeed__Product__r.Name

but depends on my logic AcctSeed__Product__c can sometimes come and some time may not. and the same goes to

AcctSeed__Expense_GL_Account__c
AcctSeed__Project_Task__c
......
1
  • What have you tried to get this working? Given it's a dynamic query that you control, why aren't you conditionally adding the xx__r.Name into the query?
    – Nick Cook
    Oct 10, 2021 at 22:06

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.