Hi there, is there a code snippet somewhere that shows the best way to check for an existing element by ID to do an upsert rather than create a new element? I went through the examples and couldn't find one that does this. Thoughts?
you could use the ID selector to get an element:
var element = $("#id-1234")
if "element" is returned or is null then you can proceed on that basis.
Thanks Phil. Doing that already.
I am using the code example to export / import to a csv and have the properties show up as columns. Unfortunately, the import duplicates everything so I was looking to tweak it so that it would update all of the properties when an element id is already found.
Is there a "round trip" set of scripts where you can export to a CSV, do some bulk updates to properties and then re-import to update the model?
Sounds like a problem in the logic of the code. When parsing the CSV file, if you are able to get an element by its ID then you can update its name, documentation, properties etc. If the element does not exist then it's up to the code whether to ignore it or create a new element. Perhaps the code example you are using needs more adjustment to suit your case?
Maybe this script could help you: https://gist.github.com/jbsarrodie/77e1e6779ace738a15c0bdcf551d68ec