Update element

Update element

mostafa.elayoubi.ds
Contributor Contributor
684 Views
2 Replies
Message 1 of 3

Update element

mostafa.elayoubi.ds
Contributor
Contributor

Hi there ! 

I'm looking for a way to update an element in the proposal by its urn or id but can't seem to find it. 

I see there is a way to update library items, but not the elements created via Forma.integrateElements.createElementHierarchy . 

Thank you for your attention! 

0 Likes
Accepted solutions (1)
685 Views
2 Replies
Replies (2)
Message 2 of 3

mostafa.elayoubi.ds
Contributor
Contributor
Accepted solution

Okay I think i figured out a way. 

I use addElement and store the path, then I use replaceElement . Is this the best way to do it? 

 

Thanks!

0 Likes
Message 3 of 3

vilde.barth
Autodesk
Autodesk

Hi @mostafa.elayoubi.ds ! Sorry for the late reply, but looks like you found the solution already!

 

Here is a code example:

const urn = mockRegisterElementInSystem() // See e.g. integrate-elements module
const { path } = await Forma.proposal.addElement({ urn })
const newUrn = mockRegisterElementInSystem() // See e.g. integrate-elements module
await Forma.proposal.replaceElement({ path, newUrn })

The code example is also available in the SDK documentation here.

 

Best, Vilde in the Forma team