AddPhone: Associate line

Version 1
    This document was generated from CDN thread

    Created by: Salim Guerid on 25-11-2013 12:43:08 AM
    Hi All,
    Trying to use the AddPhone in C#, I would like to add the line freshly created (using the addLine()) by using the pkid
     1AddPhoneReq req = new AddPhoneReq();
     2req.phone = new XPhone();
     3req.phone.name = "CSF4" + userID;
     4...
     5// Below is my naive attempt
     6 XPhoneLines lines = new XPhoneLines();
     7XDirn line = new XDirn() { uuid = linePKID };                                  
     8object[] itemsField1 = new object[4];          
     9itemsField1.SetValue(line, 0);          
    10lines.Items = itemsField1;                                  
    11req.phone.lines = lines;
    12
    13StandardResponse res = AXLAPIServiceSingleton.getInstance().addPhone(req);
    Standard error is: "There was an error generating the XML document."
    Any help will be higly appreciated.

    -Salim

    Subject: RE: AddPhone: Associate line
    Replied by: Salim Guerid on 29-11-2013 11:44:48 PM
    Hi Salim,
    Interesting question, I came accros the same issue and resolved it using the below lines:

     1XDirn dirn = new XDirn();
     2dirn.pattern = extension;
     3dirn.routePartitionName = new XFkType() { Value="Phones" };
     4XPhoneLine phoneLine = new XPhoneLine();
     5phoneLine.dirn = dirn;
     6phoneLine.index = "1";
     7XPhoneLine[] phoneLineArray = new XPhoneLine[1];
     8phoneLineArray[0] = phoneLine;
     9XPhoneLines xphoneLines = new XPhoneLines();
    10xphoneLines.Items = phoneLineArray;
    11req.phone.lines = xphoneLines;