3

I'm trying to extend the OOTB Impex to remove customersupportagentrole from customersupportmanagergroup but it not working. Please help.

this is OOB Impex.

INSERT_UPDATE CsAgentGroup;UID[unique=true];locname[lang=en];groups(uid)[mode=append];description
;customersupportmanagergroup;Customer Support Manager Group;customersupportmanagerrole,customersupportagentrole,csagentgroup,csagentmanagergroup;The Customer Support Manager Group has access to the Customer Support Backoffice's Customer Support Manager Group and Customer Support Agent Group views AND/OR the Assisted Service Module.
;customersupportagentgroup;Customer Support Agent Group;customersupportagentrole,csagentgroup;The Customer Support Agent Group has access to the Customer Support Backoffice's Customer Support Agent Group views and AND/OR the Assisted Service Module.

this is my Impex to remove customersupportagentrole from customersupportmanagergroup

INSERT_UPDATE CsAgentGroup;UID[unique=true];locname[lang=en];groups(uid)[mode=append];description
;customersupportmanagergroup;Customer Support Manager Group;customersupportmanagerrole,csagentgroup,csagentmanagergroup;The Customer Support Manager Group has access to the Customer Support Backoffice's Customer Support Manager Group and Customer Support Agent Group views AND/OR the Assisted Service Module.
;customersupportagentgroup;Customer Support Agent Group;customersupportagentrole,csagentgroup;The Customer Support Agent Group has access to the Customer Support Backoffice's Customer Support Agent Group views and AND/OR the Assisted Service Module.
HybrisHelp
  • 5,518
  • 2
  • 27
  • 65
rrusev
  • 103
  • 1
  • 15

4 Answers4

4

You are using mode=append which basically append your values to the existing collection(groups). In your case, some Impex(OOTB) may already add customersupportagentrole to customersupportmanagergroup before your Impex gets executed. Now your Impex will not override existing value, it just appends. So try using mode=replace, which basically override existing values.

INSERT_UPDATE CsAgentGroup; UID[unique=true]            ; groups(uid)[mode=replace]                                   ;                  
                          ; customersupportmanagergroup ; customersupportmanagerrole,csagentgroup,csagentmanagergroup ;                  
                          ; customersupportagentgroup   ; customersupportagentrole,csagentgroup                       ;                  
HybrisHelp
  • 5,518
  • 2
  • 27
  • 65
  • This impex will delete the customersupportmanagergroup from database instead of removing the customersupportagentrole from customersupportmanagergroup. – Farrukh Chishti Feb 20 '19 at 08:04
  • 1
    @FarrukhChishti - Can you explain your comment. – HybrisHelp Feb 20 '19 at 08:24
  • Remove query will remove the customersupportmanagergroup from the database. It will be removed from all the types that have it as an attribute. OP wants to update customersupportmanagergroup while keeping both customersupportmanagergroup and customersupportagentrole in the database. – Farrukh Chishti Feb 20 '19 at 08:29
  • 1
    Doesn't make sense. I have used INSERT_UPDATE, so what point of remove query here? another thing groups store in another relation table, so how can it remove the source? – HybrisHelp Feb 20 '19 at 08:34
  • The second query i.e. REMOVE CsAgentGroup;UID[unique=true];groups(uid) ;customersupportmanagergroup;customersupportagentrole will remove the customersupportmanagergroup from the database. – Farrukh Chishti Feb 20 '19 at 08:42
  • That query is correct. The first query with INSERT_UPDATE is correct. The second query with REMOVE is incorrect. – Farrukh Chishti Feb 20 '19 at 09:01
  • Let us [continue this discussion in chat](https://chat.stackoverflow.com/rooms/188737/discussion-between-hybrishelp-and-farrukh-chishti). – HybrisHelp Feb 20 '19 at 09:02
3

You can do it like this, if you don't use the mode operator in groups it will replace the collection with the componenets you specify

INSERT_UPDATE CsAgentGroup; UID[unique = true] ; groups(uid) ;; customersupportmanagergroup;csagentgroup,csagentmanagergroup;

or if you put [mode=remove] it will delete the component you specify

INSERT_UPDATE CsAgentGroup; UID[unique = true] ; groups(uid) [mode=remove] ;; customersupportmanagergroup;customersupportmanagerrole;

2

You need to remove for existing items in your impex.

Below code remove CsAgentGroup item (thanks @FarrukChishti for your attention)

REMOVE CsAgentGroup;UID[unique=true];groups(uid)
;customersupportmanagergroup;customersupportagentrole

We need to remove only relation so we can remove item from relation type like below or update existing like other answers.

REMOVE PrincipalGroupRelation;source[unique=true](uid);target[unique=true](uid)
;customersupportmanagergroup;customersupportagentrole
mkysoft
  • 5,392
  • 1
  • 21
  • 30
  • This impex will delete the customersupportmanagergroup from database instead of removing the customersupportagentrole from customersupportmanagergroup. – Farrukh Chishti Feb 20 '19 at 08:04
  • @mkysoft : REMOVE query will remove the instance customersupportmanagergroup from database. OP wants to update customersupportmanagergroup such that customersupportmanagergroup is no longer attached to customersupportmanagergroup but he still wants to keep customersupportmanagergroup in the databse. – Farrukh Chishti Feb 20 '19 at 08:44
0

You want to update customersupportmanagergroup so that any link connecting customersupportmanagergroup to customersupportagentrole is removed while the customersupportagentrole still exists in database. Using remove query will delete customersupportagentrole from database.

UPDATE CsAgentGroup;UID[unique=true];groups(uid)
;customersupportmanagergroup;customersupportmanagerrole,csagentgroup,csagentmanagergroup
Farrukh Chishti
  • 7,652
  • 10
  • 36
  • 60