challenges with IndexOf function
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-06-2023 07:29 AM - edited 12-06-2023 11:02 PM
Hi Team,
Am facing challenges with the IndexOf function.
below is the requirement:
Based on the Short description Assignment group should be updated.
below are the keyword and assignment groups.
If the short description contains any below keywords respective assignment group should populate in the assignment group field.
Keyword | Assignment group |
Late charges | Account department |
Smart charges | SNTP department |
Site Visit charges | SNTP department |
Other charges | Account department |
I have Created two different system properties for Above Assignment groups.
Properties are:
Account Department: Late charges, Ot.her Charges
SNTP Department: Smart charges, Site Visit charges.
My code:
Var circuitReference="Issues are related to Late charges"
Var exclude_identifier = gs.getProperty("Account department").toLowerCase().split(",");
circuitReference = circuitReference.toLowerCase();
for (var key in exclude_identifier) {
if (circuitReference.indexOf(exclude_identifier[key]) != -1) {
current.u_assignment_group = 'Account department';
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-06-2023 08:51 AM
I'm having trouble following this. Please post the entire actual script using the insert code </> icon, and the values of both system properties and we'll get you sorted.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-06-2023 08:36 PM
Hi Brad,
I have modified my query; can you check it now
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-07-2023 05:00 AM - edited 12-07-2023 05:46 AM
There is something missing with the examples you are providing. It doesn't matter that 'charges' appears multiple times, in both system properties. The indexOf method is searching the string "issues related to late charges" for the appearance of the phrases/character strings (not individual words/partial match) 'late charges', 'other charges', 'smart charges', and/or 'site visit charges'. Since there is not a value in either property for just the word 'charges', the string from the correct property will always be identified.
I confirmed this in my PDI by creating two system properties with the names and values given. I then created a Fix Script using your script with gs.print lines in place of the field assignment (and correcting the lowercase var appearances). The expected result was always returned, for iterations changing the circuitReference string also.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-06-2023 09:22 PM - edited 12-06-2023 09:24 PM
Hi
The reason it wont work is because you are making circuitReference tolowercase but do dont do it with your property values.
circuitReference = circuitReference.toLowerCase();
if (circuitReference.indexOf(exclude_identifier[key]) != -1) {
So try and change it to the below for both of the if's
if (circuitReference.indexOf(exclude_identifier[key].toLowerCase()) != -1) {