2
{
    "language": "English",
    "country": "GB",
    "successValidation": true,
    "businessEmail": "[email protected]",
    "marketingcheck": "[\"Email\",\"Phone\"]",
    "salutaion": "Mrs",
    "conFirstName": "raj",
    "conLastName": "jena",
    "areaCodeName": "001-US",
    "conPhoneNumber": "322432432",
    "skipPreviousStep": false,
    "companyId": "b2b",
    "businessCompanyAddress": "rewrwer",
    "businessCompanyAreaCode": "001-US",
    "businessCompanyPostalCode": "34324",
    "businessCompanyCity": "fsdfsdf",
    "businessCompanyCountry": "AL",
    "isSuperUser": true,
    "prefPaymethod": "Card",
    "vatRegNumber": "2132322",
    "preServicesAndIndustriesValues": {
        "Film/TV: Narrative": "Film/TV: Narrative"
    },
    "isVatNumberRequired": true,
    "isTaxPayerIdRequired": false
}

Here "marketingcheck": "["Email","Phone"]", --> this are selected values that need to assign to Marketing_Preferrence__c multipicklist field and I am getting error as this one taking string "["Email","Phone"]" like bad value

 let Contact__C = {
             
             Email__c: this.allTheFieldValues.businessEmail,
             Status__c:'Pending Email Verification',
             IsExternalAdministrator__c: this.allTheFieldValues.isSuperUser,
             BusinessAccountPortal__c:true,
             Marketing_Preferrence__c:this.allTheFieldValues.marketingcheck
}

1 Answer 1

2

You need to first parse the array and then convert it in string.

JSON.parse(this.allTheFieldValues.marketingcheck).join(';')

So your code looks like

 let Contact__C = {

         Email__c: this.allTheFieldValues.businessEmail,
         Status__c:'Pending Email Verification',
         IsExternalAdministrator__c: this.allTheFieldValues.isSuperUser,
         BusinessAccountPortal__c:true,
     Marketing_Preferrence__c:JSON.parse(this.allTheFieldValues.marketingcheck).join(';')
}
4
  • if we get the marketingcheck has array of values ["Email","Phone"] then how to parse to map for multipicklist field
    – vijay
    Nov 23, 2022 at 5:05
  • You don't need map. Just JSON.parse(this.allTheFieldValues.marketingcheck).join(';') will work fine Nov 23, 2022 at 5:08
  • thank you its worked, JSON.parse(this.allTheFieldValues.marketingcheck)?.join(';')
    – vijay
    Nov 24, 2022 at 12:42
  • 1
    Great,happy to help. Accept this answer as well so other people will get help from it as well. Nov 24, 2022 at 12:46

You must log in to answer this question.

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