Skip to main content
1-Visitor
March 13, 2015
Solved

How to remove all relationships with CLI

  • March 13, 2015
  • 1 reply
  • 3385 views

How to remove ALL relationships using CLI

after the CS151525 it would be easy, but I have to define the issueid as well

e.g.: > im editissue --query="DocID247485_HasValidates" --removeRelationships=Validates:*

*: does not work. I have to define it explicitly, haven't I?

I tired the > im editissue --query="DocID247485_HasValidates" --removeRelationships=Validates, but wo luck

Environmenrt:

I am using integrity 10.4.

Why:

There was a test document imported using validates (validated by) realtionship to the requirements, but meanwhile was defined not to use validates (validated by) but verifies (verified by) as relationship between test and requirement documents

thanks in advance for your help

Best answer by jszlatki

Jeremy,

I like your solution, but (because I'm newby in integrity) I do not understand 100 percently the using on -F

I have already the needed query as you can see above.

> im issues --query=ID247485_HasValidates --fields="Validates" > relationships.txt

- How can I tell the editissue to which item in file wich issue belongs to?

- What if there are more then one relationship to the item, which relationships I want to delete

help of -F says:

provides an alternative way to specify the selection. The specified file is a text file containing a list of file names, members, projects, or

sandboxes, one per line. The command operates on all the listed files.

I think it cannot work in this case because of 'one per line' construction,

But you gave me a good idea; the solution

I wrote a small bat file:

echo off
setlocal EnableDelayedExpansion

REM variables
set _myquery=ID247485_HasValidates
set _usr=jozsef.szlatki
set _logfile=RemovedRelationships.txt

echo All relationships are removed based on the query %_myquery% > %_logfile%

REM functions
set $get_relationships=im issues --user=%_usr% --query=%_myquery% --fields="ID,Validates" --fieldsDelim=;

REM get issuId and the relationship(s)
for /f "tokens=1,2 delims=;" %%A in ('!$get_relationships!') do (
set _dy_issueID=%%A
set _dy_relationships=%%B

REM remove issuId and the relationship(s)
im editissue --user=%_usr% --removerelationships="Validates:!_dy_relationships!" !_dy_issueID! 2>> %_logfile%

)
REM open the logfile, of course it could be pretty-printed
%_logfile%

1 reply

16-Pearl
March 13, 2015

Try this

im editissue --query="DocID247485_HasValidates" --field=Validates=

HTH Matthias

jszlatki1-VisitorAuthor
1-Visitor
March 13, 2015

Hi Matthias,

thanks for your the quick answer, unforunately it isn't working. The --removeRelationships= switch shall be defined:

--removeRelationships=value

removes related issues, where value is of the form [fieldName:]id[,...]. If no field name is specified, the Forward Relationships field is used.


The error code is also a bit funny:

Could not save modified item 247486: Invalid addRelationship format, the format is [fieldname:]issueId[linkflags].

247486: is the item id in my example test suite, where exists a relationship - ok

but why addRelationship? Is the removeRelationship an alias to addRelationship?

Worst case I shall collect all related items and put them after the colon with comma, but it would a long command

regards,

Józsi

1-Visitor
March 13, 2015

Jozsef,

Quick thought: why not run a query to pick up all the fields with relationships, write them to a text file and then use the -F switch on the im editissue to read the values to act on from your text file. This is how I quickly batch things like this.