Skip to content

Latest commit

 

History

History
82 lines (53 loc) · 4.4 KB

check-if-there-are-any-changes-on-a-session.js.markdown

File metadata and controls

82 lines (53 loc) · 4.4 KB

How to Check for Session Changes


{NOTE: }

{NOTE/}


{PANEL: Check for session changes}

  • The session's advanced property hasChanges indicates whether any entities were added, modified, or deleted within the session.

  • Note: The hasChanges property is cleared after calling saveChanges().


{CODE:nodejs changes_1@client-api\session\howTo\sessionChanges.js /}

{PANEL/}

{PANEL: Get session changes}

  • Use the session's advanced method whatChanged() to get all changes made to all the entities tracked by the session.

  • For each entity that was modified, the details will include:

    • The name and path of the changed field
    • Its old and new values
    • The type of change

Example I

{CODE:nodejs changes_2@client-api\session\howTo\sessionChanges.js /}

Example II

{CODE:nodejs changes_3@client-api\session\howTo\sessionChanges.js /}

{PANEL/}

{PANEL: Syntax}

{CODE:nodejs syntax_1@client-api\session\howTo\sessionChanges.js /} {CODE:nodejs syntax_2@client-api\session\howTo\sessionChanges.js /}

ReturnValue
Record<string, DocumentsChanges> Dictionary containing list of changes per document ID
DocumentsChanges Type Description
fieldOldValue object Previous field value
fieldNewValue object Current field value
change string Type of change that occurred. Can be:
"DocumentDeleted", "DocumentAdded","FieldChanged", "NewField", "RemovedField", "ArrayValueChanged", "ArrayValueAdded", "ArrayValueRemoved"
fieldName string Name of field on which the change occurred
fieldPath string Path of field on which the change occurred
fieldFullName string Path + Name of field on which the change occurred

{PANEL/}

Related Articles

Session