Tarun
Tarun

Reputation: 3165

How to create defect using "VersionOne SDK JAVA API" Client

I am trying to create a defect using "VersionOne.SDK.Java.APIClient 13.0.1" jar.

        Oid projectId = services.getOid(scopeId);
        IAssetType assetType = this.metaModel.getAssetType("Defect");
        Asset newAsset = services.createNew(assetType, projectId);

        IAttributeDefinition nameAttribute = assetType.getAttributeDefinition("Name");
        IAttributeDefinition Custom_FailureType = assetType.getAttributeDefinition("Custom_FailureType.Name");
        IAttributeDefinition defectStatus=assetType.getAttributeDefinition("Status.Name");
        IAttributeDefinition defectSeverity=assetType.getAttributeDefinition("Type.Name");
        IAttributeDefinition defectSource=assetType.getAttributeDefinition("Source.Name");
        IAttributeDefinition defectVersion=assetType.getAttributeDefinition("VersionAffected");

        //newAsset.addAttributeValue(Custom_FailureType, "My New Defect");
        newAsset.setAttributeValue(nameAttribute, "My New Defect");
        newAsset.setAttributeValue(Custom_FailureType, "Functional Failure");
        newAsset.setAttributeValue(defectStatus, "Done");
        newAsset.setAttributeValue(defectSeverity, "Minor");
        newAsset.setAttributeValue(defectSource, "sales");
        newAsset.setAttributeValue(defectVersion, "1.2.3");

        services.save(newAsset);

        System.out.println(newAsset.getOid().getToken());
        System.out.println(newAsset.getAttribute(nameAttribute).getValue());

but getting the following error:

"Cannot assign new value to a read-only attribute: Defect.Custom_FailureType.Name"

The field Custom_FailureType is mandatory so i cant create defect without assigning value for Custom_FailureType.

Could you please tell me how can we create defect.

Upvotes: 1

Views: 357

Answers (1)

Daniel Gruesso
Daniel Gruesso

Reputation: 31

This is not supported in version 13 of the SDK. Please download version 15:

https://community.versionone.com/Developers/Developer-Library/Documentation/Java_SDK

Upvotes: 1

Related Questions