Is it possible to put conditions in Datalookups Defination Assignment Data Lookup [dl_u_assignment]

chanikya
Kilo Sage

Hi All,

we created Data lookup in Servicenow
Source Table : Task
Matcher Table : dl_u_assignment

is it possible to put conditions in OOB Data lookup definations (Assignment Data Lookup [dl_u_assignment]) ?

chanikya_0-1759529504436.png

 

TASK Table is common sharing for Incident, Problem, Change.   So this Data lookup should run only When Parent record  is Incident.

use case : Example : we have two Assignment Groups ( Assignment Group 1, Assignment Group 2) on  Task table

when  Task type selected as ABC then Assignment Group 1 should be populate by ABC group
When  Task type selected as  BBC then Assignment Group 2 should be populate by BBC group

Vice versa.

if make Group field empty then Task type should be empty. if Task type Empty then Group field should be empty.

can achieve it from OOB Data lookups or not ? please share your opinions 

4 REPLIES 4

kaushal_snow
Mega Sage

@chanikya ,

 

Yes, you can implement conditional logic in Data Lookup Definitions, including the dl_u_assignment table, to control field values based on specific conditions such as the parent record type; while ServiceNow's out-of-the-box (OOB) Data Lookup Definitions don't provide a direct way to add conditions within the definition itself, you can achieve this functionality by combining Data Lookup Definitions with Business Rules or Client Scripts.....

 

If you found my response helpful, please mark it as ‘Accept as Solution’ and ‘Helpful’. This helps other community members find the right answer more easily and supports the community.

 

Thanks and Regards,
Kaushal Kumar Jha - ServiceNow Consultant - Lets connect on Linkedin: https://www.linkedin.com/in/kaushalkrjha/

Hi @kaushal_snow ,
Can you share some examples how can we achieve with combination of BR. that would be helpful for me. 

NavinAgarwal
Kilo Guru
Hi @chanikya ,
 
You can use Data Lookup Definitions (DLDs) with Conditions using different lookup tables or use custom conditions for scripting.
 
  1. Configure the DLD to use different lookup tables: 
    You can define conditions within the DLD itself to determine which lookup table to use for a particular value.
    • Example: Create two lookup fields for an "AccountNumber"The first uses the "Customer" table for IDs less than 1,000, and the second uses the "NewCustomers" table for IDs greater than or equal to 1,000.
  2. Use custom conditions for scripting: 
    For more complex scenarios, use the "Custom condition" operator to manually script the condition, allowing for more intricate logic to select the correct lookup table.
    • Example: In TimeXtender, a custom script can handle complex logic that simple conditions might not cover.
Combining with Business Rules (BRs):
 
  1. Use an After Business Rule with a high order: 
    To have a business rule override a DLD's output, create an "after" business rule with an order number equal to or higher than the DLD's order. 
     
    • Example: If your DLD has an order of 100, set your BR's order to 200 or higher to ensure it runs after the DLD and can modify its results. 
       
  2. Add criteria to the Business Rule: 
    Within the BR, you can add further criteria to determine when it should override the DLD's value. 
     
    • Example: A BR could check if a customer has a specific "High Priority" status. If they do, the BR would then look up and set a preferred customer name from a different table, effectively overriding the name that the DLD might have provided. 

Steps for a Combined Scenario:

 

  1. Define the Data Lookup: 
    Create a Data Lookup Rule that maps a field (e.g., CustomerID) to a value from a lookup table.
     
  2. Add the conditional logic to the DLD: 
    Add a condition to the lookup definition to specify when this lookup should be used, such as when CustomerID is less than 1,000.
     
  3. Create a second lookup for different criteria: 
    For CustomerIDs 1,000 and above, create a second lookup with its own condition to pull a different value from another table.
     
  4. Implement the Business Rule: 
    Create an After Business Rule that runs on the same table. This BR would check for additional criteria, like a CustomerStatus field.
     
  5. Override the value: 
    If the BR's criteria are met, it will perform its own lookup or set a new value, overriding the value that the Data Lookup Definition initially provided, according to ServiceNow documentation. 
     
    If you found my response helpful, could you please mark it as ‘Accept as Solution’ and ‘Helpful’? This small action goes a long way in helping other community members find the right answers more easily and supports the community. 

Hi @NavinAgarwal , thanks for sharing details.
Source Table : Ticket
Matcher Table : dl_u_assignment

Datalookups works on change . So are these conditions works only when on changes happened on form level ? ( not after Insert, Not After Update) ?

OnChange : we are looking the feasibility Data Lookups should works only when Parent field has Incident number .

chanikya_0-1759757867221.png

chanikya_1-1759757903614.png

chanikya_2-1759758569290.png

Use custom conditions for scripting: Please let us know where do I add custom conditions ?
in side Data Lookup Definitions (DLD )? means we have to crate any custom script on DLD ? or please advise me 


we need this on OnChange . On Ticket record we have Parent field. When Parent field value having Incident then it self only DLD related Assignment Datalookups apply, if Ticket has Problem or other record, then DLD related Assignment Datalookups should not apply on Ticket. 


On above screenshot we have two records if Type = Database , HRSD  group should be populated in Assignment Group 2.
if Type = Software , ITOM  group should be populated in Assignment Group.

Please advise on this.