arnoudkooi / sn-scriptsync

Use sn-scriptsync in combination with SN Utils to be able to code in VS Code, including all benefits of a full fledged code editor
https://marketplace.visualstudio.com/items?itemName=arnoudkooicom.sn-scriptsync
Other
43 stars 28 forks source link

Adds a prompt for the user to enter a filename, if a record with an identical name already exists. #88

Closed Blenderpics closed 1 year ago

Blenderpics commented 1 year ago

Feature can be turned off with the config option 'sn-scriptsync.promptForFileNameOnColision': false, in which case the behaviour from before (auto naming by applying a suffix) will be restored.

In case of the "studio sync", the behaviour was not changed and auto naming will always be used, since it's not sensible for the user to enter a new file name for every conflict in the scope.

The _map.json file will now be respected when syncing from servicenow to vs-code.
Custom file names will therefore stay custom when syncing the file a second time.

arnoudkooi commented 1 year ago

I think if you would do either "Load Scope" it would create a duplicate When clicking the save icon again from the instance it would prompt again.

In general, I'm not sure if I want manual prompting in the first place.

Blenderpics commented 1 year ago

Clicking the save icon again after the initial sync won't trigger the prompt.

The first sync saves the name into the _map.json, the following syncs will lookup that name (in line 1047).
nameToSysId[cleanName] != postedJson.sys_id will evaluate to false because of that, so the while loop that does the prompt won't execute.

However, the scope sync does not respect already existing entries in the _map.json, so it will create a duplicate.

Should be simple to implement a fix for the scope sync so it respect existing entries as well. I can look into that.

The prompting isn't something i am particular keen on myself.

For my usecase it would be sufficient if existing entries in the _map.json files would be respected.

If you are willing to merge this behaviour without the prompting, i can create a separate pull request only containing that part. (Including the scope sync fix)