Posting data with an alternate primary key
I have a REST service that posts a lot of data to a table in Appian (136k+ rows). The problem is the primary key in the service is not the same primary key that Appian is using. I cannot match the keys because, the service's key is unpredictable. Government data, yea!
For my REST post I simply need it to find the record with a matching value (if it exists) then update it, or else create a new record.
a!localVariables(
local!value: cast(
'recordType!{b44d0eeb-090e-4c8f-b858-1f684423adbc}DCQ Weekly Extract',
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)
),
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
)
)
)
)
)
