- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-29-2025 04:03 AM
Suppose there is a field on a record produces type. If type is "Incident", an Incident should be created. If type is "Problem", then a Problem should be created. How will you achieve this?
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-31-2025 11:27 PM
Hello @neehas,
current
and producer
objects within a script to access and modify the new record being created.
-
1. Define the Field:Create a field (variable) in your Record Producer that will dictate the type or table of the record to be created. This could be a drop-down, a radio button, or another field that allows the user to select the desired type.
-
2. Add a Script:Go to the "What it will contain" section of your record producer and add a script to the "Script" field.
-
3. Conditional Logic:Within the script, use conditional statements (like
if/else
orswitch
) to check the value of the field you defined in step 1. -
4. Record Creation:Depending on the field's value, use the
current
object to set the appropriate values for the new record's fields. For example, if the field indicates an "Incident," you might set thetable_name
to "incident" and other incident-specific fields. -
5. Example:
// Check the value of the "Type" field (assuming it's named "type")
if (producer.type == "Incident") {
current.table_name = "incident"; // Set the table for the record
// Set other Incident-specific fields as needed
current.short_description = "Generated Incident";
current.caller_id = current.user_id; // Example: Set caller to current user
} else if (producer.type == "Problem") {
current.table_name = "problem";
// Set other Problem-specific fields as needed
current.short_description = "Generated Problem";
current.caller_id = current.user_id;
}
// ... other conditions for different record types
- Test: Order the record producer from the Service Catalogue to verify that the correct record type is created based on the selected field.
If this is helpful, please hit the thumbs up button and accept the correct solution by referring to this solution in the future; it will be helpful to them.
Thanks & Regards,
Abbas Shaik
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-01-2025 07:33 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-31-2025 11:27 PM
Hello @neehas,
current
and producer
objects within a script to access and modify the new record being created.
-
1. Define the Field:Create a field (variable) in your Record Producer that will dictate the type or table of the record to be created. This could be a drop-down, a radio button, or another field that allows the user to select the desired type.
-
2. Add a Script:Go to the "What it will contain" section of your record producer and add a script to the "Script" field.
-
3. Conditional Logic:Within the script, use conditional statements (like
if/else
orswitch
) to check the value of the field you defined in step 1. -
4. Record Creation:Depending on the field's value, use the
current
object to set the appropriate values for the new record's fields. For example, if the field indicates an "Incident," you might set thetable_name
to "incident" and other incident-specific fields. -
5. Example:
// Check the value of the "Type" field (assuming it's named "type")
if (producer.type == "Incident") {
current.table_name = "incident"; // Set the table for the record
// Set other Incident-specific fields as needed
current.short_description = "Generated Incident";
current.caller_id = current.user_id; // Example: Set caller to current user
} else if (producer.type == "Problem") {
current.table_name = "problem";
// Set other Problem-specific fields as needed
current.short_description = "Generated Problem";
current.caller_id = current.user_id;
}
// ... other conditions for different record types
- Test: Order the record producer from the Service Catalogue to verify that the correct record type is created based on the selected field.
If this is helpful, please hit the thumbs up button and accept the correct solution by referring to this solution in the future; it will be helpful to them.
Thanks & Regards,
Abbas Shaik
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-01-2025 07:33 AM