- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-18-2024 09:05 AM - edited 03-18-2024 09:16 AM
Hi All,
I have requirement
1)company table (core_company) Default view.
2)contract table (ast_contract)
In ast_contract table there is field Vendor which is reference to core_company table.
My requirement is we should created new related list- contract in core_company table in default view . In that contract we should want to display contracts based on that company and contracts state is = Active/Expired one's only.
I'm expecting the contract related list at the highlighted place in the below snip. please let us know how to achieve this.
Thank you
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-19-2024 03:14 AM
@Sirri , as i can see there are 4 choice for state Draft, active, expired, cancelled so in the below i have removed expired and cancelled to show Draft and active ones only similarly if your requirement is different you can add encoded query or you can add current.addQuery .
(function refineQuery(current, parent) {
// Add your code here, such as current.addQuery(field, value);
current.addQuery('vendor.name',parent.name);
current.addQuery('state', "!=",'expired');
current.addQuery('state',"!=", "cancelled");
})(current, parent);
Please mark this comment as Correct Answer/Helpful if it helped you.
Regards,
Swathi Sarang
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-18-2024 09:36 AM
Hi @Sirri
https://www.servicenow.com/community/developer-forum/how-to-create-a-related-list/m-p/1920737
If my response proves useful, please indicate its helpfulness by selecting " Accept as Solution" and " Helpful." This action benefits both the community and me.
Regards
Dr. Atul G. - Learn N Grow Together
ServiceNow Techno - Functional Trainer
LinkedIn: https://www.linkedin.com/in/dratulgrover
YouTube: https://www.youtube.com/@LearnNGrowTogetherwithAtulG
Topmate: https://topmate.io/atul_grover_lng [ Connect for 1-1 Session]
****************************************************************************************************************
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-18-2024 10:14 AM
From this related list go ahead and add the filter active to true
https://{your instance}.service-now.com//now/nav/ui/classic/params/target/sys_ui_related_list.do%3Fsys_id%3D3e828dda37313000158bbfc8bcbe5dbc%26sysparm_record_target%3Dsys_ui_related_list%26sysparm_record_row%3D2%26sysparm_record_rows%3D3%26sysparm_record_list%3DnameCONTAINScore_company%255EORDERBYname
and once you open the related list go ahead and add your filter active to true, this should work on ur default view
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-18-2024 10:19 AM
Hi @Sirri
Go to https://{instance name}.service-now.com/now/nav/ui/classic/params/target/sys_ui_related_list.do%3Fsys_id%3D3e828dda37313000158bbfc8bcbe5dbc%26sysparm_record_target%3Dsys_ui_related_list%26sysparm_record_row%3D2%26sysparm_record_rows%3D3%26sysparm_record_list%3DnameCONTAINScore_company%255EORDERBYname
and check if there is related list of contract table if not add them on the form.
Then come back to this page and add the filter condition it should work for you.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-18-2024 10:38 AM
Hi @Sirri ,
You can create a Relationship between Company table and Contract Table ,
System Definition ->Relationship
create something like below,
On company table Configure-> Related List add the new created Relationship it would look something like this ,
Please mark this comment as Correct Answer/Helpful if it helped you.
Regards,
Swathi Sarang
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-18-2024 11:05 PM
Hi @swathisarang98 ,
Thanks for response.
In relation ship(sys_relationship) table you mention.
current.addQuery('vendor.name',parent.name);
after that how to mention state in only one of Active or Expired
Thank you