Event: On Load Message: uniqueCompany=Like | countries=Thailand Level: info View: Create view
Hey @Sudarsana G ,
I assume you are trying to set or restrict the country field, and the unique company portion is working? If this is wrong understanding, let me know.
My version will use "Location"..
I didn't check if they are not part of jira-users, so just directly assess group name like "TEST_CompanyB-Canada", which is similar to yours:
const companyLocationPairs = groupNames
.filter(name => name.startsWith('TEST_'))
.map(name => {
const parts = name.replace("TEST_", "").split('-');
return { company: parts[0], location: parts[1] };
});
Here is where there are 2 things which I don't know what you want to do.
1. If I assume you are trying set the value of country directly - you probably can add locations below uniqueCompany like:
const uniqueCompany = [...new Set(companyLocationPairs.map(pair => pair.company))][0];
const locations = companyLocationPairs.map(pair => pair.location);
then set the locations like:
const locationToSet = locations[0];
// map location/country to the context/option ID
const optionId = locationToOptionId[locationToSet];
if (optionId) {
await getFieldById("customfield_XXXXX").setValue(optionId); }
2. If I assume you are trying to restrict the visibility of selection to a set of countries (because of the setOptionsVisibility), then maybe you want to map a the logical groups of countries/locations based on criteria, maybe like:
const countryToGroup = {
"Canada": { "Canada" : "26202", "United States" : "26201"},
"Thailand": { "Thailand": "25966", "India" : "26203"} // or whatever grouping logic..
or just directly restrict everything else by adding the hide other options filter and set.OptionsVisibility(NotcountryOptionsIds, false), as you already have something to set what to show:
getFieldById("customfield_1334").setOptionsVisibility(countryOptionIds, true)
I hope I somehow make sense...if I don't make sense, open a Support Ticket with us and our support engineers can give a much better and clearer explanation *hides the pain*.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.