dynamicdan / sn-filesync

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

Domain Separation: the domain chosen in the browser is ignored (due to session based setting) #3

Open dynamicdan opened 9 years ago

dynamicdan commented 9 years ago

If you are using domain separation then the records will only ever be updated based on the users domain.

If you change the domain in the web browser then it is only set per session and not per user. There is no workaround other than using the standard ServiceNow interface to do changes to records that need to be in a different domain than the current user.

2 proposals:

  1. Save the domain information in a meta file when the record is first downloaded. Use this information to always set the domain field for the record correctly.
  2. Let the user specify the domain via a comment like /* DOMAIN MUST BE: global */ in the file. Would help future users to ensure they do not edit the file in the wrong domain.

Perhaps both proposals should be implemented as domain separation can be problematic to debug.


When we download a file we have the full sys_domain details that can be used to update the record correctly. The domain data looks like this:

sys_domain: '86799cc40f943100308a0eece1050e77',
sys_domain_path: '!!!/!!$/',

OR

sys_domain: 'global',
sys_domain_path: '/',

In any case, these 2 properties could be stored somewhere. In the file is not so ideal because we need to pollute someones code/xhtml block. Saving in a .meta dir would be ok but makes for more files. We should instead extend the existing .sync concept and save out JSON files like this:

{
  syncHash: "231234827398472937492sadsasdas12",
  sys_domain: '86799cc40f943100308a0eece1050e77',
  sys_domain_path: '!!!/!!$/',
  sys_updated_on: '2015-03-25 11:26:57',
  sys_updated_by: 'joe.blogs',
  sys_scope: 'global',
  sys_id: 'd31951010f8b7100f5a07f5ce1050ec9',
}
dynamicdan commented 8 years ago

Saving more meta data now possible. Need to add logic for handling diff domains (if even possible).