I have a Write Record WebAPI that needs to start a process. The purpose of the process is to notify a user group that a new speaker request has been added to the system. I keep getting an error when trying to kick off the process, "PMSO Volunteer Request can only be indexed into using square brackets or the index function"
I created a blank process (start node and end node) called "PMSO New Speaker Request". There is one process variable created "entryId" that is set to be a parameter.
The Web API
a!localVariables( local!value: cast( 'recordType!{ca4c278b-1034-49bc-af7d-e4c16cf132b6}PMSO Volunteer Request', a!fromJson(http!request.body) ), a!writeRecords( records: local!value, /* * Construct an HTTP response to return to the caller */ onSuccess: {a!httpResponse( statusCode: 200, /* * Set an HTTP header that tells the client that the body of the response will be in JSON format */ headers: { a!httpHeader(name: "Content-Type", value: "application/json") }, /* *In the response body, return the records created or updated */ body: a!toJson(fv!recordsUpdated) ), a!startProcess( processModel: cons!PMSO_NewSpeakerRequest, processParameters: { entryid: local!value.entryId } ) }, onError: a!httpResponse( statusCode: 500, headers: { a!httpHeader(name: "Content-Type", value: "application/json") }, body: a!toJson( a!map( message: "Write request has failed", error: fv!error ) ) ) ) )
Data is posted to the Record Type, PMSO Volunteer Request, but the process is not started.
Discussion posts and replies are publicly visible
You cast your local variable "value" to a record type. Then you need to use the correct syntax in line 27 as pointed out in the error message.
Thank you for the quick response.
Just to confirm, the following casts the body of the API call into a record type.
local!value: cast( 'recordType!PMSO Volunteer Request', a!fromJson(http!request.body) ),
Then I needed to reference the data using the correct syntax.
a!startProcess( processModel: cons!PMSO_NewSpeakerRequest, processParameters: { entryId: local!value['recordType!PMSO Volunteer Request.fields.entryid']
This now seems to work (I am posting the record and passing the value to the process), yet I am still getting an error on the "onError" portion of the API call.
It is throwing a 500 Status Code and I am not sure why. That is coded in the onError portion of the writeRecord function (see code in my initial post). I turned on logging, now I am trying to figure out where the logs are stored.
You cannot call two smart service functions. Put that write records into the process.
Ugg!!! I was afraid of that!!