How can I use javascript var to set the attribute.metadata field in callserver?

260    Asked by Ajit yadav in Java , Asked on Oct 10, 2022

tried to get the description of the title correct. If you think there might be a better one that describes the scenario better, please suggest!


In lightning components, I have a cpq_Configure component. In the helper I have a function that gets the experience attribute. This experience attribute is an array with just 1 item. The QR_Field__c is a metadata field, which is equal to a field on the quote object. For example, there can be multiple experiences, and each experience will have their QR_Field__c field set to a different field on the quote object.


Now what I want to do is stamp v.experience[0].QR_Field__c with the value in the attribute arr. I am wanting to stamp the quote field that is in this metadata field with the value in arr, which would theoretically be an amount.tried to get the description of the title correct. If you think there might be a better one that describes the scenario better, please suggest!


In lightning components, I have a cpq_Configure component. In the helper I have a function that gets the experience attribute. This experience attribute is an array with just 1 item. The QR_Field__c is a metadata field, which is equal to a field on the quote object. For example, there can be multiple experiences, and each experience will have their QR_Field__c field set to a different field on the quote object.


Now what I want to do is stamp v.experience[0].QR_Field__c with the value in the attribute arr. I am wanting to stamp the quote field that is in this metadata field with the value in arr, which would theoretically be an amount.


When it comes to calling the server, I'm setting the quote fields directly through newItem. For example, setting newItem.OpportunityId = component.get('v.quoteName');. OpportunityId is a field that is on the quote object. However, I want to see if there's a way instead of directly calling a field on the quote object to call a var in the javascript function. For example, qrField's value is 'Quota_Relief_VOC__c' for the particular experience it is (CX) because that's what the value is for it on the metadata record. 

Answered by ajith Jayaraman

Here is the solution to this callserver dilemma that I was able to find out. If I pass qrField over to my Apex method, I am be able to use the put method (https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_methods_system_sobject.htm).


It would look something like this in Apex:

@isAuraEnabled
Static void createUpdateQuote(Quote q, String qrField, String myValue){
q.put(qrField, myValue);
}

Your Answer

Interviews

Parent Categories