cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - Learn all about PTC Community Badges. Engage with PTC and see how many you can earn! X

Creating Test Session with defined parameters - MultiValue issue

kbi
4-Participant
4-Participant

Creating Test Session with defined parameters - MultiValue issue

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

1 ACCEPTED SOLUTION

Accepted Solutions
PE_NangaSystems
6-Contributor
(To:kbi)

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

View solution in original post

3 REPLIES 3
awalsh
17-Peridot
(To:kbi)

What message are you getting back when it fails?

 

PE_NangaSystems
6-Contributor
(To:kbi)

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

kbi
4-Participant
4-Participant
(To:PE_NangaSystems)

It works your way,

 

Thanks a lot!

Top Tags