Is it possible to edit employee groups using suite...
# suitescript
j
Is it possible to edit employee groups using suitescript? for example add or remove members from a group? I know the URL to call to add/remove people but that seems pretty hacky.
a
e
I just tried to add employees to a group via the console using both standard and dynamic modes, but was unsuccessful because the
groupmembers
sublist is static.
I was able to load the group record just fine
a
😞
hacky URL calls it is! 😂
e
That doesn't necessarily mean I exhausted all the options, or even did what I was trying correctly, but yeah it does look that way 🙂
a
I mean, jen isn't a noob I assume she tried all the obvious things, she has a pretty good track record of asking questions that leave me scratching my head which doesn't really happen that often but jen has like an 80% hit rate 😂
j
lol
this was one of my boring questions, sorry
but yeah I came to the same conclusion.
for reference, you can attach people by just calling this URL /app/crm/common/crmgroup.nl?savedsearch=-1&grouptype=Employee&dynamic=F&issalesrep=F&continue=Continue&islist=T&e=T&_action=ATTACH&id=id_of_group&member=>id_of_group_member_1%05id_of_group_member_2%05id_of_group_member_3
e
Ah the classic
\x05
separator. Haven't had to deal with that in quite a while
j
yeah, I’ve had to delve into that to deal with splitting up the string of ‘Item Options’ on an item line before, it’s somewhat familiar territory.
e
Copy code
addContactsToGroup(datain) {
                const groupId = datain.data.groupId;
                const contacts = datain.data.contacts;
                if(contacts && contacts.length > 0) {
                    contacts.forEach(contactId => {
                        record.attach({
                            record: {
                                type: 'contact',
                                id: contactId
                            },
                            to: {
                                type: 'entitygroup',
                                id: groupId
                            }
                        });
                    })
                }
            }
👀 2
e
^ Wouldn't have thought to do this via record attachments
a
yeah good shout @ehcanadian
j
oh DUH of course that would work.
r
I would have never guessed record attachments work for this.
j
they work for random stuff, I’ve used them for adding contacts to vendors before
e
Would be lovely to have this relationship (sublist vs attachment) identified in the records browser
💯 2
j
Would be lovely to have 5 million dollars magically appear in my living room.
Cool, using record.attach and record.detach I think I’ll be able to achieve my end goal which is to be able to control what groups an Employee is in from their Employee record page.
✅ 1
🙌 1
m