Appearance
question:I would like to display contents of a HTML field( a custom field created ) from change form in email body. The {field_name} does not work. Is there a way to achieve this.
answer:To include the contents of an HTML field (a custom field you've created on a form such as a Change form) in the email body and have it properly render or display, you cannot use the simple `{field_name}` notation directly, especially if the email body type is set to plain text. This is because ServiceNow by default escapes HTML content when using the `{}` notation to prevent XSS (Cross-Site Scripting) vulnerabilities. However, when your email body is set to type "HTML", you can use the `{mail_script:script_name}` notation in the email template along with a mail script to inject the HTML content unescaped. Here's how you can achieve that: # Step 1: Create a Mail Script 1. Navigate to **System Notification > Email > Notification Email Scripts**. 2. Click "New" to create a new Email Script. 3. Give your script a **Name**, for instance, `DisplayHTMLField`. 4. In the **Script** field, write a script that fetches and returns the HTML field content. Assuming your custom field is named `u_custom_html_field`, your script would look something like this: ```javascript (function runMailScript(/* GlideRecord */ current, /* TemplatePrinter */ template, /* Optional EmailOutbound */ email, /* Optional GlideRecord */ email_action, /* Optional GlideRecord */ event) { // Ensure that current record is not null and the HTML field exists if (current && current.u_custom_html_field) { return current.u_custom_html_field.getHTMLValue(); // or just .toString() if getHTMLValue() is not appropriate } return ''; // return empty string if field does not exist or current is null })(current, template, email, email_action, event); ``` # Step 2: Use the Mail Script in Your Email Notification Template 1. Navigate to **System Notification > Email > Notifications**. 2. Open the notification where you want to include the HTML content. 3. In the **Message HTML** field (ensure the email format is set to HTML), use the `{mail_script:script_name}` notation where you want the HTML content to appear. For example: ``` <p>Here is the content from our custom HTML field:</p> {mail_script:DisplayHTMLField} ``` This configuration tells ServiceNow to execute the "DisplayHTMLField" mail script and insert the returned HTML content unescaped into the email body. # Important: - Make sure that the HTML content you include does not break the email's overall layout and is safe to display (i.e., it does not contain harmful scripts or inappropriate content). - Depending on your instance's version and configurations, the exact navigation path or availability of certain functionalities may vary. - When dealing with HTML content, always validate and sanitize the input to prevent security issues. By following these steps, you should be able to include the contents of a custom HTML field from a change form (or any other form) in the email body of a ServiceNow notification.
question:I'm using Decision table to trigger the group approvals based on catalog form variables. The approvals are triggering when I'm submitting(Admin role) the form but while user(itil role) is trying to submit, the group approval's are not triggering. Why the approvals are not triggering to user who has ITIL role? I've configured any role restriction in Flow designer or Decision table.
answer:If group approvals are triggering correctly when an administrator submits the form but not when a user with the `itil` role submits, there could be several areas to investigate. Although you've mentioned there's no role restriction configured in the Flow Designer or Decision Table, it's worthwhile to double-check certain configurations and also assess other potential issues: # 1. **Re-check Role Restrictions:** - **Flow Designer:** Ensure the flow that's supposed to trigger the approval has no role restrictions that might inadvertently prevent it from executing for users with the `itil` role. Sometimes, flows or subflows might have execution restrictions based on roles. - **Decision Table:** Double-check the decision table used for triggering group approvals. Make sure there isn't an overlooked condition or criteria that differentiates between users based on their roles. # 2. **Catalog Item Access Control:** - **Catalog Item:** Verify whether there are any Access Control Rules (ACLs) applied to the Catalog Item or the variables within the Catalog Item that might be affecting how different roles interact with the form. Although it might not be directly related to the Flow Designer or Decision Tables, ACLs can affect the visibility and editability of form fields, potentially impacting the flow's conditions or data availability. # 3. **Group Membership Verification:** - **Approval Group:** Make sure the group designated to approve the request includes the expected users or has the expected hierarchy. If the flow is trying to fetch and assign an approval to a specific group based on form input or other conditions, verify that these conditions are met equally for admins and `itil` users. # 4. **Variable Visibility and Readability:** - Check whether all form variables used in the decision-making process for triggering approvals are visible and readable by the `itil` role. There might be variable-level ACLs that restrict reading or writing to variables for certain roles. # 5. **Debugging the Flow:** - Utilize the **Debug** feature in Flow Designer to trace the execution of the flow when an `itil` role user submits the form. Look for any conditions that aren't met or any errors in the flow's logic that could explain why the approval isn't being triggered. # 6. **User Context and Impersonation:** - If possible, impersonate a user with the `itil` role and submit the form to see firsthand what might be going wrong. Sometimes, real-time testing as the affected user can uncover nuances not otherwise evident. # 7. **Review Flow Conditions:** - Specifically look at the conditions within the flow or decision table that might be evaluating user roles, group memberships, or other attributes differently depending on who is submitting the request. # Additional Considerations: - **Logging and System Diagnostics:** Look into system logs for any errors or warnings that might be generated when an `itil` role user submits the form. ServiceNow offers comprehensive logging that can help identify issues not immediately visible through configuration screens. - **Consult ServiceNow Documentation and Community:** If the issue persists, consult ServiceNow documentation and community forums. It's possible others have encountered similar role-based discrepancies and might offer insights or solutions. By methodically reviewing these areas and conducting thorough testing under different user roles, you should be able to identify and resolve the discrepancy causing group approvals to not trigger for users with the `itil` role.
question:Does "onCellEdit" client scripts works on workspace UI ?
answer:As of my last update in 2023, "onCellEdit" client scripts are designed to work with the ServiceNow platform's traditional UI, specifically within List Views, where they enable customization of the behavior when a user edits a cell inline. However, the ServiceNow Agent Workspace and the newer workspace experiences represent a significant UI overhaul compared to the traditional platform interface. These workspace environments aim to provide a more integrated and streamlined experience for agents and other end-users. Because of this, not all client-side scripting and customizations available in the traditional UI, including "onCellEdit" client scripts, are directly applicable or functional within workspace environments. ServiceNow has been continuously enhancing capabilities and customization options within the Agent Workspace, including introducing the UI Builder for more recent versions, which allows for significant customization of workspace experiences. However, specific customization options like "onCellEdit" might not natively work or have a direct equivalent in the workspace UI due to its different architectural and interaction models. # Alternatives and Recommendations: - **Check Documentation:** Always check the most current ServiceNow product documentation or community forums for any updates or new features that might support similar customization needs in the workspace UI. - **Explore Workspace Features:** The workspace UI offers different mechanisms for customization and interaction. Explore capabilities such as UI Actions, Workflows, Playbooks, and Virtual Agent for enhancing the user experience in the workspace. - **Custom Widgets:** For more advanced customization within the workspace, consider creating custom widgets using the ServiceNow Now Experience UI Framework, especially if you're using a version that supports UI Builder for workspace customization. - **Feedback to ServiceNow:** If specific customization capabilities like "onCellEdit" are critical for your workspace UI use cases, consider providing feedback to ServiceNow through your account management or directly via the ServiceNow Community. ServiceNow frequently updates its platform based on user feedback and needs. - **Consultation with ServiceNow Professionals:** Given the rapid pace of updates and enhancements in the ServiceNow platform, consulting with ServiceNow professionals or the ServiceNow community can provide insight into best practices and alternative approaches for achieving your customization goals within the workspace UI. Remember, with each ServiceNow release, new capabilities and enhancements are introduced, so it's beneficial to stay updated with the latest release notes and documentation for the most accurate and current information.
question:In the Incident table, there's a short description with a suggestion. When the suggestion is clicked, a pop-up box appears containing all the data. However, the user only wants to see 2 specific data
answer:Customizing the popup box (also referred to as a "hover" popup) to show only specific data fields when hovering over a reference field like the short description in the Incident table requires some adjustments. These customizations typically involve creating or modifying a UI Macro that defines the content of the hover popup, and potentially adjusting the Dictionary Entry for the field you're interested in (if it uses a specific template for its hover behavior). # Step 1: Identify or Create the UI Macro First, determine if there's already a UI Macro that controls the hover popup for your field. If not, you can create one. 1. **Navigate** to **System UI > UI Macros**. 2. **Search** for any existing macros related to the Incident table hover popup. The name might give you a hint, but if not, you might need to create a new one. 3. **Create** a new UI Macro if necessary: - Click "New". - Give it a **Name**. - In the **Template** field, define your XML structure to display only the two specific data fields you're interested in. Here's an example template structure: ```xml <j:jelly trim="false" xmlns:j="jelly:core" xmlns:g="glide" xmlns:j2="null" xmlns:g2="null"> <g2:evaluate var="jvar_incident" object="{sys_id}" as="true"> var inc = new GlideRecord('incident'); if (inc.get('{sys_id}')) { /* Access your fields here e.g., inc.short_description */ } </g2:evaluate> <table> <tr> <td>Field 1:</td> <td>{jvar_incident.field1_name}</td> </tr> <tr> <td>Field 2:</td> <td>{jvar_incident.field2_name}</td> </tr> </table> </j:jelly> ``` Replace `field1_name` and `field2_name` with the actual field names you want to display. # Step 2: Link the UI Macro to the Field If creating or modifying a UI Macro: 1. Go to **System Definition > Dictionary**. 2. Find the dictionary entry for the field you're interested in (e.g., the Short Description field in the Incident table). 3. In the attributes section, add or modify the attribute to specify your UI Macro. The attribute might look something like this: `ref_contributions=my_ui_macro_name`, where `my_ui_macro_name` is the name of the UI Macro you created or modified. # Step 3: Test Your Changes After making these changes: 1. **Clear your browser cache** or use an incognito window to avoid any caching issues. 2. **Navigate** to the Incident table and hover over the field you've customized to check if the modifications are displaying as expected. # Note Customizations involving UI Macros and Dictionary attributes require careful testing, especially in a sub-production environment, to ensure they don't impact other functionalities or cause performance issues. It's also a good practice to check the latest ServiceNow documentation or community resources as ServiceNow's features and best practices evolve over time.