By Reid Caulfield @Reid_Caulfield
Hello all. Here's what I need to do
- Set 2 particular named Groups to "Active";
- However, while the names of the groups in question is mostly the same from session to session, part of the group name does change, and so I need to activate groups using only the part of the name that stays the same.
Example:
ENG 51 Work Grp
I need to ignore the "ENG" because this changes session to session.
Thank you for any help you can offer!
- samuel henriques @samuel_henriques
Hello Reid,
This is an adaptation of Christian's script found here:
Checking if the group is active or not #post-4in this line
setGroupActive("51 Work Grp", true);
It looks for a group with "51 Work Grp" included on name and true is meant to activate, you can use
false
to deactivate.
So, in your example the group name is "ENG 51 Work Grp", " 51 Work Grp" is included on the name.I left two lines,
setGroupActive("51 Work Grp", true); setGroupActive("52 Work Grp", true);
for two groups, add as manny as you need.
Hope it helps./** * @param {string} groupName * @param {boolean} targetValue Set to true (active) or false (inactive) */ function setGroupActive(groupName, targetValue) { let grp = sf.ui.proTools.mainWindow.groupListView.childrenByRole('AXRow').map(r => { let btn = r.childrenByRole('AXCell').allItems[1].buttons.first; return { groupName: r.childrenByRole('AXCell').allItems[1].buttons.first.title.value.split(/-\s/)[1], btn, isActive: btn.title.invalidate().value.indexOf('Active ') === 0, row: r, }; }).filter(g => g.groupName.includes(groupName))[0]; if (!grp) throw `Group with name "${groupName}" was not found`; if (grp.isActive !== !!targetValue) grp.btn.elementClick(); } setGroupActive("51 Work Grp", true); setGroupActive("52 Work Grp", true);
- RReid Caulfield @Reid_Caulfield
This works, Samuel. Thank you for you patience, I'm slowly understanding the construct.