dynamicdan / sn-filesync

2-way sync ServiceNow field values to local files
MIT License
66 stars 37 forks source link

Allow using sys_ids to match records and ensure future proof. #5

Closed dynamicdan closed 8 years ago

dynamicdan commented 9 years ago

The system currently relies on a "search" style query returning the correct result by checking the table and a field value to find the correct record. In the case of UI actions "Save" is a common name and there are not really any other reasonable fields other than "action_name" to use (which is still not unique). The same can be true when having multiple CMS themes with stylesheets named like "layout".

This has not proven to be a destructive issue because the developer will know if they have the correct record or not and once a record is saved, the hash of the contents is always used to compare records therefore avoiding overwrite of other instance records with the same name.

SOLUTION 1. Allow files to be named in the format "sys_id_25928b23377375002cfb696043990e62.js" so that it is guaranteed we have a unique record. Optionally allow other descriptive text to be added to the name like "sys_id_25928b23377375002cfb696043990e62_save button.js".

SOLUTION 2. Save the actual sys_id in the ./sync_data/ cache to reduce human error. If the file is named like "sys_id_save_btn.js" then the record "save_btn" is downloaded via query search but subsequent requests are made via the sys_id that is saved with the other meta data. This ensures that the user checks the resulting download the first time but doesn't need to worry about future records that might also be named "save_btn".

SOLUTION 3. To make the first run fool proof, enforce file naming like "sys_id_25928b23377375002cfb696043990e62_save_btn.js" and then rename the file (and cache data to match) as "sys_id_save_btn.js". This approach may cause potential editor app confusion.