Community Tip - If community subscription notifications are filling up your inbox you can set up a daily digest and get all your notifications in a single email. X
Hello,
I'm developing software, that is creating test session based on test specification, and i already handled getting data from PTC, but i can't create Test Session using CmdRunner.
try
{
PTC.Command Cmd = new PTC.Command(PTC.Command.IM, "createissue");
PTC.MultiValue mv1 = new PTC.MultiValue("=");
PTC.MultiValue mv2 = new PTC.MultiValue("=");
PTC.MultiValue mv3 = new PTC.MultiValue("=");
mv1.add("Summary");
mv1.add("AutoSessionTest1");
mv2.add("Project");
mv2.add("/MySampleProject/Electronics");
mv3.add("Test Objective");
mv2.add("473680");
Cmd.addOption(new PTC.Option("type", "Test Session"));
Cmd.addOption(new PTC.Option("field", mv1));
Cmd.addOption(new PTC.Option("field", mv2));
Cmd.addOption(new PTC.Option("field", mv3));
PTCResponse.Response R = InputEngine.Run(Cmd);
MessageBox.Show("Test Session Created");
}
catch (Exception exc)
{
MessageBox.Show(exc.Message);
}
Do you have an Idea why it won't work?
Best regards,
Chris
Solved! Go to Solution.
haven´t used MultiValued for some time now, but I believe you only have to use it that way
Option fieldOption = new Option("field"); MultiValue multiValue = new MultiValue("="); multiValue.add("fieldName"); multiValue.add("fieldValue");
MultiValue multiValue1 = new MultiValue("=");
multiValue.add("fieldName1");
multiValue.add("fieldValue1");
// Add the MultiValue object to the Option object. fieldOption.add(multiValue);
fieldOption.add(multiValue1);
the integrations builder guide unfortunately has no sampe, this is copied from the javadoc..
I personally don´t use multivalue
you can also add the same command option multiple time, e.g.
Command cmd = new Command(Command.IM);
cmd.setCommandName("createissue");
cmd.addOption(new Option("field", "Shared External ID=123456"));
cmd.addOption(new Option("field", "Summary=Summary_123456"));
...
if you want to do troubleshooting you can try running the command using CLI, then you should get a proper error message.
you cannot rely on ex.getmessage(), sometimes the ex has a nested one. the builder guide pdf has some good samples
Phil
What message are you getting back when it fails?
haven´t used MultiValued for some time now, but I believe you only have to use it that way
Option fieldOption = new Option("field"); MultiValue multiValue = new MultiValue("="); multiValue.add("fieldName"); multiValue.add("fieldValue");
MultiValue multiValue1 = new MultiValue("=");
multiValue.add("fieldName1");
multiValue.add("fieldValue1");
// Add the MultiValue object to the Option object. fieldOption.add(multiValue);
fieldOption.add(multiValue1);
the integrations builder guide unfortunately has no sampe, this is copied from the javadoc..
I personally don´t use multivalue
you can also add the same command option multiple time, e.g.
Command cmd = new Command(Command.IM);
cmd.setCommandName("createissue");
cmd.addOption(new Option("field", "Shared External ID=123456"));
cmd.addOption(new Option("field", "Summary=Summary_123456"));
...
if you want to do troubleshooting you can try running the command using CLI, then you should get a proper error message.
you cannot rely on ex.getmessage(), sometimes the ex has a nested one. the builder guide pdf has some good samples
Phil
It works your way,
Thanks a lot!