Creating Related Lists for Contract and Entitlements on Incident form

prudhvig
Tera Expert

Hi,

I have Customer Service Application in my Servicenow instance which consists of contracts and entitlements. Each customer company of ours might have 1 or more than 1 contracts and obviously, 1 contract has multiple entitlements. So, after referring to the documentation, I have decided to create two related lists on Incident form --> one for Contract and the other for Entitlements. And to do this, I got to know that I need to create or specify relationship.

The Customer Company name is one of the fields in my Incident form. When the Company is selected, the Related Contracts should be viewed and based on the Contract, the Entitlements should be shown.

I am unable to understand how to do it as I hardly have any knowledge on Servicenow.

Please help. Thanks in advance.

1 ACCEPTED SOLUTION

oharel
Kilo Sage

Hi Raju,



Where is the contracts and entitlemensts data stored? I will assume on a different table than incidents, and so the first part seems straight forward - create a relationship between the incident table and the contracts table:


System Definition -> Relationships -> New


Name: incident contracts


Applies to table: incident


Queries from table: ast_contract --> or your contracts table


Script:


(function refineQuery(current, parent) {



  // Add your code here, such as current.addQuery(field, value);


  current.addQuery('company', parent.company); //company is the field name in your contract table and incident. Might be called u_company if you added it manually...


})(current, parent);



harel


View solution in original post

7 REPLIES 7

oharel
Kilo Sage

Hi Raju,



Where is the contracts and entitlemensts data stored? I will assume on a different table than incidents, and so the first part seems straight forward - create a relationship between the incident table and the contracts table:


System Definition -> Relationships -> New


Name: incident contracts


Applies to table: incident


Queries from table: ast_contract --> or your contracts table


Script:


(function refineQuery(current, parent) {



  // Add your code here, such as current.addQuery(field, value);


  current.addQuery('company', parent.company); //company is the field name in your contract table and incident. Might be called u_company if you added it manually...


})(current, parent);



harel


I have done as you said. Instead of ast_contract, I used ast_service because I think we want Service Contracts.



This how my relationship looks like :



Screenshot (10)_LI.jpg



Is that right? If so, what should I do next to get the Related List? Thanks in advance.


Hi Harel,



I went and added that Related list to my Incident Form. Thank you. I will get back to you once I test it properly.


Hi Harel,



I have done exactly what you told me to do. I have also added the related list to my Incident form. But the related list shows all the Contracts in my instance instead of showing just the ones related to the particular company.



What should I do here. Thanks in advance.