Skip to main content
vishwv0002
March 1, 2024
Question

MongoDb connected system is throwing exception error for "Update One in Collection Operation" in integration

  • March 1, 2024
  • 4 replies
  • 0 views

We are using Appian's MongoDB connected system. In our integration object we are using "Update One in Collection" operation to update a specific element of an Array of Documents.

Below are the Filter JSON, Update Instructions JSON and Error Message

--- Filter JSON ---

a!toJson( { '$and': { { { "_id": { '$oid': "6407f59c20f85f4027c3655b" } } } } } )

--- Update Instructions JSON ---

a!toJson( { '$set': { "form_schedule.$[elem].formName.oldValue": "forms old value 1" }, '$arrayFilters':{ m_field( "elem.amendmentComments", m_eq( "Rk Form Number" ) ) } } )

--- ERROR MESSAGE --

Mongo Write Exception error-result-guidance Write operation error on server serff-develop-shard-00-02.ylpdg.mongodb.net:27017. Write error: WriteError{code=2, message='No array filter found for identifier 'elem' in path 'form_schedule.$[elem].formName.oldValue'', details={}}.

4 replies

davidj137213
March 1, 2024

Seems that this expression form_schedule.$[elem].formName.oldValue is returning a does not return anything, so Mongo cannot make any update.

Could you check  the contents of the array? 

srmm0001
March 4, 2024

Hi,


Adjust your Update Instructions JSON to align the path with how you're filtering the element in $arrayFilters:


JSON

a!toJson( { '$set': { "form_schedule.$[elem].formName.oldValue": "forms old value 1" }, '$arrayFilters': { m_field( "elem.amendmentComments", m_eq( "Rk Form Number" ) ) } } )