- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-27-2024 08:46 PM
hi,my question is how to get related list buttons,if i click on that button it should redirect to the another table list view,if we select records there it should reflect in current record related list,same like add button in impacted services related list in incident form,i used related list action but i was unable to get it,if you guys have any accurate solution provide me.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-27-2024 09:41 PM
Hi @Charani
Step 1: Create a Custom UI Action
1. Navigate to System Definitions > UI Actions.
2. Click on “New” to create a new UI action.
3. In the form that appears, provide a name for your UI action and select the table this UI action should apply to (this would typically be the table you want to add records from).
4. In the “Action name” field, you can specify a unique identifier for the action.
5. Make sure to select “List Context Menu” for the type of UI action if you want it to appear as a button or link in the context menu of a list view.
6. In the “Script” field, write the necessary JavaScript to redirect the user to the desired list view. You will likely need to use a URL to direct to the target table’s list view, potentially with some filtering applied. Here’s a simplified example:
var url = ‘some_table_list.do?sysparm_query=yourEncodedQuery’;
action.setRedirectURL(url);
Replace some_table_list with the name of your target table, and yourEncodedQuery with any specific filtering you want to apply to the list view.
### Step 2: Set Up a Many-to-Many Relationship (Optional)
If your use case involves a many-to-many relationship (e.g., needing to associate multiple records from another table with your current record), consider setting up a many-to-many relationship table if you haven’t already. This is what allows the association between entities, akin to how Impacted Services work on incident records.
1. Navigate to System Definition > Tables & Columns.
2. Click on “New” to create a new table that will act as your many-to-many table.
3. Set up this table to have two reference fields: One pointing to your original table, and one pointing to the table you’re adding records from.
### Step 3: Use Reference Qualifiers (Optional)
For the “Add” functionality that allows for selecting records to associate with your current record, a Reference Qualifier can be useful. This is especially relevant if you’re working with a form and want to ensure only relevant records show up in a reference field or related list.
1. When setting up your reference field in the many-to-many table, you can specify a reference qualifier to filter the available records. This can be a simple encoded query or an advanced script depending on your needs.
### Step 4: Add Records to the Related List Upon Selection
This part is trickier since, after navigating away and selecting the records, you’ll need a way to associate those selected records back with your original record. This typically involves capturing the selected records’ IDs and updating the many-to-many table to link these records to your original record.
One approach is to customize the list view being used for selection so that selecting a record executes a script to update the many-to-many relationship table. This often involves custom development and may benefit from an intermediate page or UI action that handles the logic.
Note: Please Mark this Helpful and Accepted Solution. If this Helps you to understand. This will help both the community and me..
- Keep Learning
Thanks & Regards
Deepak Sharma
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-27-2024 09:41 PM
Hi @Charani
Step 1: Create a Custom UI Action
1. Navigate to System Definitions > UI Actions.
2. Click on “New” to create a new UI action.
3. In the form that appears, provide a name for your UI action and select the table this UI action should apply to (this would typically be the table you want to add records from).
4. In the “Action name” field, you can specify a unique identifier for the action.
5. Make sure to select “List Context Menu” for the type of UI action if you want it to appear as a button or link in the context menu of a list view.
6. In the “Script” field, write the necessary JavaScript to redirect the user to the desired list view. You will likely need to use a URL to direct to the target table’s list view, potentially with some filtering applied. Here’s a simplified example:
var url = ‘some_table_list.do?sysparm_query=yourEncodedQuery’;
action.setRedirectURL(url);
Replace some_table_list with the name of your target table, and yourEncodedQuery with any specific filtering you want to apply to the list view.
### Step 2: Set Up a Many-to-Many Relationship (Optional)
If your use case involves a many-to-many relationship (e.g., needing to associate multiple records from another table with your current record), consider setting up a many-to-many relationship table if you haven’t already. This is what allows the association between entities, akin to how Impacted Services work on incident records.
1. Navigate to System Definition > Tables & Columns.
2. Click on “New” to create a new table that will act as your many-to-many table.
3. Set up this table to have two reference fields: One pointing to your original table, and one pointing to the table you’re adding records from.
### Step 3: Use Reference Qualifiers (Optional)
For the “Add” functionality that allows for selecting records to associate with your current record, a Reference Qualifier can be useful. This is especially relevant if you’re working with a form and want to ensure only relevant records show up in a reference field or related list.
1. When setting up your reference field in the many-to-many table, you can specify a reference qualifier to filter the available records. This can be a simple encoded query or an advanced script depending on your needs.
### Step 4: Add Records to the Related List Upon Selection
This part is trickier since, after navigating away and selecting the records, you’ll need a way to associate those selected records back with your original record. This typically involves capturing the selected records’ IDs and updating the many-to-many table to link these records to your original record.
One approach is to customize the list view being used for selection so that selecting a record executes a script to update the many-to-many relationship table. This often involves custom development and may benefit from an intermediate page or UI action that handles the logic.
Note: Please Mark this Helpful and Accepted Solution. If this Helps you to understand. This will help both the community and me..
- Keep Learning
Thanks & Regards
Deepak Sharma
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-27-2024 10:12 PM
could you please explain the fourth part