Please enable JavaScript to view this site.

QPR Knowledge Base 2019.1

Navigation: Developer's Guide > QPR Web Services Foundation > Functions

SetAttribute

Scroll Prev Top Next More

Revision history:

Introduced in QPR 8.1

Last changed in QPR 2019.1.1

 

Set a single attribute value to one or more objects defined in the objectIds parameter.

 

Synopsis:

 

void SetAttribute(string sessionId, string objectIds, string attribute, string value, string options)

 

Return Value:

 

None.

 

Parameters:

 

sessionId: String. ID of an authenticated session.

objectIds: String. A comma-separated list of FullID's of objects to which the attribute value should be added.

attribute: String. Name of the attribute to be set.

value: String. Value of the attribute to be set. Note that all values must be provided as XML-compatible string values.

options: String. A comma-separated list of options for the command. Note that there can be also mandatory options specific to product and object type. The following options are specifically supported by the SettAttribute function:

InputValuesInMeasurementUnitFormat: true | false. Defines if the measure's own unit format is assumed when converting input values from string to float. Default value is true. If this option is false, decimal separator is assumed to be "." and thousand separator empty.

ForceTypeChange: true | false. When setting elementtypeid for a Metrics element, and the element has linked elements, the new element type may not have a corresponding linked element type for some of them. In that case, if ForceTypeChange is true, those linked elements are deleted. Otherwise, the operation is aborted.

 

Example Procedure:

 

ServiceClient client = new ServiceClient("WSHttpBinding_IService");

string sessionId = client.Authenticate("qpr", "demo");

string[][] attributes = { new string[] { "Description", "Hello from QPR Web Services Foundation" }, new string[] { "Category", "Initiative" } };

string objectId = client.CreateObject(sessionId, "PO", "actionplan", "Action Plan created via WS API", "", attributes, "");

MessageBox.Show("Created object with ID " + objectId);

// add more attributes to the object

client.SetAttribute(sessionId, objectId, "status", "Waiting for approval", "");

client.LogOff(sessionId);

client.Close();