mirror of
https://github.com/netbox-community/netbox.git
synced 2024-05-10 07:54:54 +00:00
Fixes #9651 - Document Pre-Change process for scripts
This commit is contained in:
@ -129,6 +129,19 @@ The Script object provides a set of convenient functions for recording messages
|
|||||||
|
|
||||||
Log messages are returned to the user upon execution of the script. Markdown rendering is supported for log messages.
|
Log messages are returned to the user upon execution of the script. Markdown rendering is supported for log messages.
|
||||||
|
|
||||||
|
## Change Logging
|
||||||
|
|
||||||
|
To generate the correct change log data when editing an existing object, a snapshot of the object must be taken before making any changes to the object.
|
||||||
|
|
||||||
|
```python
|
||||||
|
if obj.pk and hasattr(obj, 'snapshot'):
|
||||||
|
obj.snapshot()
|
||||||
|
|
||||||
|
obj.property = "New Value"
|
||||||
|
obj.full_clean()
|
||||||
|
obj.save()
|
||||||
|
```
|
||||||
|
|
||||||
## Variable Reference
|
## Variable Reference
|
||||||
|
|
||||||
### Default Options
|
### Default Options
|
||||||
|
Reference in New Issue
Block a user