Author Message
Smoroffko
Joined: Nov 5, 2015
Messages: 22
Offline
When I try to make a change to a Incoming Call Handling Trunk-Group I get a "System.NullReferenceException when ever I try to set the below settings.


sType.Called_Length.SetValue("10", 3);
sType.Called_Number.SetValue("1234567890", 3);
sType.Del.SetValue("10", 3);
sType.Insert.SetValue("12345", 3);


If I remove / comment this code out there is no longer an error. I've written similar code with different types without issue. Any recommendations?

Here is the full code:


public void setLabTrunkIncomingCallHandling(string trunkGroup)
{
AvayaLabCM.SystemManagementService client = new AvayaLabCM.SystemManagementService();
client.Timeout = 120000;

try
{
client.Credentials = new NetworkCredential(Properties.Settings.Default.CMLabUser, Properties.Settings.Default.CMPass);
client.PreAuthenticate = true;
client.SoapVersion = System.Web.Services.Protocols.SoapProtocolVersion.Soap11;
client.RequestEncoding = System.Text.Encoding.UTF8;

AvayaLabCM.submitRequestType req = new AvayaLabCM.submitRequestType();

AvayaLabCM.modelChoices choices = new AvayaLabCM.modelChoices();
choices.Items = new object[1];
choices.Items.SetValue(new AvayaLabCM.IncomingCallHandlingType(), 0);
req.modelFields = choices;
req.objectname = string.Empty;
req.qualifier = "trunk-group " + trunkGroup;
req.operation = "display";

AvayaLabCM.returnType results = client.submitRequest(req);

Console.WriteLine("Result Code: " + results.@return.result_code);
Console.WriteLine(Environment.NewLine + "Message: " + results.@return.message_text);

foreach (AvayaLabCM.IncomingCallHandlingType value in results.@return.result_data.Items)
{
AvayaLabCM.IncomingCallHandlingType sType = new AvayaLabCM.IncomingCallHandlingType();
sType.Called_Length.SetValue("10", 3);
sType.Called_Number.SetValue("1234567890", 3);
sType.Del.SetValue("10", 3);
sType.Insert.SetValue("12345", 3);

choices.Items.SetValue(sType, 3);
req.modelFields = choices;
req.objectname = "";
req.qualifier = "trunk-group " + trunkGroup;
req.operation = "change";

results = client.submitRequest(req);
}

Console.WriteLine("Result Code: " + results.@return.result_code);
Console.WriteLine("Message: " + results.@return.message_text);

client.Dispose();
client.release(null);
}
catch (Exception ex)
{
client.Dispose();
client.release(null);

Console.WriteLine(ex.ToString());
}
}
CraigJohnson5
Joined: Oct 24, 2013
Messages: 413
Offline
Are you able to update the values with the SMS test tool? The values that you are setting are of Array type and you have to set the position. There is a sample app called System Management Services Web Portal sample application that uses button data which is also array type.
Smoroffko
Joined: Nov 5, 2015
Messages: 22
Offline
Obviously I am doing something wrong with these Set Value functions. I am trying to change a button in the Station type and keep getting a "Object reference not set to an instance of an object". I feel like I am missing something simple here. Do you have any suggestions?


try
{
var client = createClient("Cm1");

AvayaAES.StationType sType = new AvayaAES.StationType();
sType.Button_Data_1.SetValue("ec500", 5);

AvayaAES.submitRequestType req = new AvayaAES.submitRequestType();
AvayaAES.modelChoices choices = new AvayaAES.modelChoices();
choices.Items = new object[1];
choices.Items.SetValue(sType, 1);
req.modelFields = choices;
req.objectname = string.Empty;
req.qualifier = "xxxxx";
req.operation = "change";

AvayaAES.returnType results = client.submitRequest(req);
releaseClient(client);

Console.WriteLine(results.@return.result_code.ToString());
Console.WriteLine(results.@return.result_data.Items[0].ToString());
}
catch(Exception ex)
{
Console.WriteLine(ex.ToString());
}
CraigJohnson5
Joined: Oct 24, 2013
Messages: 413
Offline
As stated before button data is of ArrayType so you would need to set the position and the value of that position. You need something more like the sample application that I mentioned. Here is an edited snippet from that application:

ArrayType Button1 = of.createArrayType();

ArrayType Button2 = of.createArrayType();

//first position in string array is going to be the position in the button
//data array list. Second position is the value for ButtonData1, and third
//position is ButtonData2 value
Button1.setPosition(Integer.parseInt(buttonDataArray[0]));
Button1.setValue("" + buttonDataArray[1]);
Button2.setPosition(Integer.parseInt(buttonDataArray[0]));
Button2.setValue("" + buttonDataArray[2]);

//We need to set the button data. There is no "set" function for ArrayList data
//so we have to use the get method to set the ArrayList properly.
sType.getButtonData1().add(Button1);
sType.getButtonData2().add(Button2);


If you need additional coding assistance please consider upgrading you membership level and opening a Devconnect Technical Support Ticket.
Go to:   
Mobile view