Best answer

Duplicated id for trigger ourput

  • 4 August 2022
  • 2 replies
  • 15 views

HI community,

In my system users can create their own fields and call it as they wish. The only restriction is using _ at the beginning because that’s how we represent the id of the data. Since every output trigger needs an id, I was just converting the _id to the id field, but this creates a conflict when a user has an id in their data. Like this:

{
_id: '123123',
id: '2'
}

My questions is if there is a good solution for solving this problem.

I was thinking about not using the _id for the output id but I wouldn’t use what to use instead.

Thank you! 

 

icon

Best answer by Diego Orca 9 August 2022, 20:33

View original

2 replies

Userlevel 7
Badge +11

@Diego Orca 

Might not be the best solution but the simplest might be just to preserve the ‘id’ field to a new key prior to overwriting it with the ‘_id’ field?

I fixed the issue encapsulating the data into an object like this:

{
id: '1',
data:{
id: 'example1',
name: 'example'
}
}

 

Reply