I tried to get the description of the title correct. If you think there might be a better one that describes better the scenario, 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.

enter image description here

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 (refer to picture below). enter image description here Any suggestions on how to pass this through using a javascript var? Or better suggestions on how to accomplish this in general? Here is the markup so you can get a better grip at this.

createUpgradeQuote : function(component, event, helper){
    console.log('Configure Helper: CreateUpgradeQuote');

    var exp = component.get('v.exp');
    var arr = component.get('v.arr');

    //Set experience array
    var experiences = component.get('v.experienceMetaData');
    var experience = _.filter(experiences, {'Code__c' : exp});
    component.set('v.experience', experience);

    var qrField = component.get('v.experience[0].QR_Field__c');
    console.log('The qrField value is: ' + qrField);        

    var Quote = component.get('v.quote');
    var bundleName = component.get('v.selectedBundle')[0].Name;
    var serviceQlis = component.get('v.serviceQlis');
    var quoteType = component.get('v.quoteType');
    var templateCodes = '';
    var newItem = {};

    _.forEach(serviceQlis, function(value) {
        if(value.Template_Code__c != null) {
            templateCodes+=value.Template_Code__c + ',';

    //if(quoteType == 'change-dates') {
        //newItem.'qrField' = licenseARR 


    newItem = JSON.parse(JSON.stringify(Quote));
    newItem.Name = component.get('v.quoteName');
    newItem.OpportunityId = component.get('v.opportunity.Id');
    newItem.Pricebook2Id = '01s500000001tHMAAY';
    newItem.License_Term_in_months__c = component.get('v.quoteTerm');
    newItem.Quote_Type__c = "New License";
    newItem.License_Length_Input__c = component.get('v.quoteTerm');
    newItem.XM_Products__c = component.get('v.selectedBundle')[0].Name;
    newItem.PostBundleDiscountAmount__c  = component.get('v.netTotal');
    newItem.License_Start_Date__c = component.get('v.quoteStartDate');
    newItem.License_End_Date__c = component.get('v.quoteEndDate');
    newItem.Last_Configuration__c = new Date();
    newItem.Service_Template_Codes__c = templateCodes;
    //quoteEndDate = moment.utc(quoteEndDate).subtract(1, 'days').format('DD-MM-YYYY');
        function(response) {               
            var recordId = response.Id;

            record : newItem,
            startDate : component.get('v.quoteStartDate')

1 Answer 1


Here is the solution to this 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:

Static void createUpdateQuote(Quote q, String qrField, String myValue){

q.put(qrField, myValue);


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .