0

I am trying to pass multiple opp Ids in order to link a file that is getting uploaded to those opps. I have my list of records Ids that I am passing to the apex but I am getting an error, {message: "Value provided is invalid for action parameter 'recordIds' of type 'LIST'"}

In my javascript I have the list of recordIds which is as follows: 4 here is recordIds [{"id":"0068A00000BaRAQQA3"},{"id":"0068A00000BaRASQA3"}]

Here is my javascipt:

  //from button to add new file
handleClick(){
  const recordIds =  this.oppIdsToLink;
    const {base64, filename, recordId} = this.fileData

    console.log('4 here is recordIds ' + JSON.stringify(recordIds));

    uploadFile({ base64, filename, recordId, recordIds }).then(result=>{
        this.fileData = null
        let title = `${filename} uploaded successfully!!`
        this.toast(title)
    })
    console.log('after the uploadfile');
}

here is my simplified apex where the recordIds is null (the other vars are populated):

public static string uploadFile(String base64, String filename, String recordId, List<String> recordIds) {
  
    system.debug(logginglevel.info, '!! 1 here is the recordId ' + recordId);
    system.debug(logginglevel.info, '!! 1 here is the recordIds ' + recordIds);
    system.debug(logginglevel.info, '!! 1 here is the filename ' + filename);

}

Any help would be greatly appreciated!

2 Answers 2

0

Instead of List of String take as List of Sobject because id is coming in form object not as list. Replace sobject with object name of which you are passing the recordId.

Either return Id like this from js-

["0068A00000BaRAQQA3","0068A00000BaRASQA3"]

0
  1. Perhaps make the

uploadFile(String base64, String filename, String recordId, List recordIds) to uploadFile(String base64, String filename, String recordId,String
recordIds)

  1. Essentially you are stringifying your ListRecord Ids by using JSON.stringify

  2. Either you remove JSON.stringify from your LWC component or you make the Data type String in your uploadFile apex method

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.