{"revision":"c10276e953456835cdbb1f3a60d58ae1980be353","document":{"id":39803,"path":"platform-administration/t_EnableDynCreationForRefFields.md","title":"Enable dynamic creation for reference fields","bundle":null,"doc_type":null,"release":"australia","body":"\n# Enable dynamic creation for reference fields\n\nWhen dynamic creation is enabled, entering a nonexistent value in a reference field creates a new record on the referenced table instead of returning an error.\n\n## Before you begin\n\nRole required: personalize\\_dictionary\n\n## About this task\n\nBy default, a user must enter a value in a reference field that matches an existing record in the table that the reference field refers to. For example, the **Caller** field in an Incident must have a value that is an existing user. You can enable dynamic creation to create a new record on the referenced table when a user enter a nonexistent value in a reference field instead of returning an error.\n\n## Procedure\n\n1.  Right-click the field label in the form and select **Configure Dictionary**.\n\n2.  Populate the following fields \\(you may need to configure the Dictionary form\\):\n\n    -   **dynamic\\_creation**: Select the check box.\n    -   **dynamic\\_creation\\_script**: Enter a script that dynamically creates the record.\n3.  Click **Update**.\n\n    Examples:\n\n    You could use the following `dynamic_creation_script` to create a record on the referenced table.\n\n    ```\n    current.name = value;\n    current.insert();\n    ```\n\n    **Note:** The parent object can be used to access anything from the parent record.\n\n    You could create a script include named MyUserReferenceCreator with the following contents:\n\n    ```\n    var MyUserReferenceCreator = Class.create();\n    MyUserReferenceCreator.prototype = {\n        initialize: function() {\n        },\n     \n        create: function(current, value) {\n            current.name=value;\n            return current.insert();\n        },\n     \n        type: 'MyUserReferenceCreator'\n    }\n    ```\n\n    When the script include is created, the following `dynamic_creation_script` generates a new location for an invalid reference field value:\n\n    ```\n    new MyUserReferenceCreator().create(current, value);\n    ```\n\n\n**Related topics**  \n\n\n[Configuring the form layout](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/platform-administration/configure-form-layout.md)\n\n"}}