Topic by Uma Guduru
Content
Hi,
Im trying to create a new incident , also at the same time trying to set the value of a custom field which is menu item, i get error message , i have uploaded the error message
Please check the code below and let me know what is it that im doing wrong.
----------------------------------------------------------------------------------------------------------------------------------
newIncident.Subject = "This is a test incident - Please Ignore";
// Assign Incident Queue
NamedID incidentQueueID = new NamedID();
incidentQueueID.ID = new ID();
incidentQueueID.ID.id = 32;
incidentQueueID.ID.idSpecified = true;
newIncident.Queue = incidentQueueID;
//Create an IncidentContact to add as the primary contact on the new Incident
IncidentContact incContact = new IncidentContact();
NamedID contactNamedID = new NamedID();
contactNamedID.ID = new ID();
contactNamedID.ID.id = 252431;
contactNamedID.ID.idSpecified = true;
incContact.Contact = contactNamedID;
newIncident.PrimaryContact = incContact;
GenericField[] customField = new GenericField[1];
customField[0] = new GenericField();
customField[0].name = "prioritytype";
customField[0].dataType = DataTypeEnum.NAMED_ID;
customField[0].dataTypeSpecified = true;
NamedID nid = new NamedID();
ID nameid = new ID();
nameid.id = 1;
nameid.idSpecified = true;
nid.ID = nameid;
customField[0].DataValue = createmenuDataValue(nid);
GenericObject customFieldsc = new GenericObject();
customFieldsc.GenericFields = customField;
customFieldsc.ObjectType = new RNObjectType() { TypeName = "IncidentCustomFieldsc" };
GenericField customFieldsPackage = new GenericField();
customFieldsPackage.name = "c";
customFieldsPackage.dataType = DataTypeEnum.OBJECT;
customFieldsPackage.dataTypeSpecified = true;
customFieldsPackage.DataValue = new DataValue();
customFieldsPackage.DataValue.Items = new[] { customFieldsc };
customFieldsPackage.DataValue.ItemsElementName = new[] { ItemsChoiceType.ObjectValue };
newIncident.CustomFields = new GenericObject
{
GenericFields = new[] { customFieldsPackage },
ObjectType = new RNObjectType { TypeName = "IncidentCustomFields" }
};
//Build the RNObject[]
RNObject[] newObjects = new RNObject[] { newIncident };
//Set the processing options
CreateProcessingOptions options = new CreateProcessingOptions();
options.SuppressExternalEvents = false;
options.SuppressRules = false;
//Invoke the Create Operation
try
{
ClientInfoHeader clientInfoHeader = new ClientInfoHeader();
clientInfoHeader.AppID = "Basic Create";
RNObject[] results = _client.Create(clientInfoHeader, newObjects, options);
MessageBox.Show("New Incident with ID: " + results[0].ID.id + " created.");
}
catch (Exception ex)
{
MessageBox.Show("Error Message -> " + ex.Message);
}
}
private static DataValue createmenuDataValue(NamedID nid)
{
DataValue dv = new DataValue();
dv.Items = new object[] { nid };
dv.ItemsElementName = new ItemsChoiceType[] { ItemsChoiceType.NamedIDValue };
return dv;
}
Image
