Community Tip - Need to share some code when posting a question or reply? Make sure to use the "Insert code sample" menu option. Learn more! X
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
Solved! Go to Solution.
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%
Try this
im editissue --query="DocID247485_HasValidates" --field=Validates=
HTH Matthias
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
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.
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%
That's great Jozsef. For some processes, a batch file is needed. Thanks for posting your code, as it should help future users to do this kind of thing!
Thanks Jeremy. Yes it was my goal as well. Could you describe the -F option briefly with a small example? Sometimes I would need a bit more examples in the integrity doc. Thanks in advance
The -F switch, on the commands that allow it, reads variables from a text file instead of from the command line. For example:
im users -will list all the IM users on the system
im viewuser {username} -will give details of a user
im users > users.txt -will write a list of all users to a text file named users.txt
im viewuser -F users.txt -will give a list of details for each user in the users.txt file