This is a problem that I am facing in Oracle Integration Cloud when using the assignment expression editor. In my problem, I get records from a DB table that have name/value columns. I have variables for the possible names and want to assign the values in an assign action: varParticipantId, varOrgId, varPersonId (there are more). So, if the NAME column is ParticpantId and the VALUE column is 12345 then I want to set the variable varParticipantId = 12345.
If I have a result from the table like this (SELECT FROM TABLE WHERE ID = "AAAA"), then my xpath works and varParticipantId is set to the result of the XPATH query, 12345.
ID | NAME | VALUE |
---|---|---|
AAAA | ParticipantId | 12345 |
AAAA | OrgId | 54321 |
The XML would look like this (simplified):
<response>
<records>
<id>AAAA</id>
<name>ParticipantId</name>
<value>12345</value>
</records>
<records>
<id>AAAA</id>
<name>OrgId</name>
<value>54321</value>
</records>
</response>
This is the assignment expression (simplified): $getRefs/getResponse/....../records[name=‘ParticpantId’]/value
However if the result set doesn’t have the record I’m looking for then it fails, e.g. (SELECT FROM TABLE WHERE ID = "BBBB")
ID | NAME | VALUE |
---|---|---|
BBBB | OrgId | 98765 |
<response>
<records>
<id>BBBB</id>
<name>OrgId</name>
<value>98765</value>
</records>
</response>
What I want to do in this case is to set the variable varParticipantId = “”, i.e. have a default return of null if records[name=‘xxxxxx’] is not found. Is this doable with XPATH?
This is the XPATH query
$getRefs/getResponse/....../records[name=‘ParticpantId’]/value
If no record with name = ParticpantId, I get this error
summary=<summary>The <from> value is invalid.Xpath expression associated with <from> in copy assign activity is invalid.There is an user error that results in missing element value(s) in the xpath query.</summary>,activity=<activity>29726865-BpAss30-BpSeq7.3-54</activity>,query=<query>$messagecontext_37.parameters/../nsmpr8:getResponse/nsmpr8:components.schemas.get-response-wrapper/nsmpr0:records[(nsmpr3:referenceAttributeName = “ParticpantId”)]/nsmpr3:referenceAttributeValue_0x737063_</query>
Someone posted this answer and subsequently withdrew it. Putting the XPATH expression inside the string() function returns "" if the expression evaluates to null. Makes sense.