Hi,
I have some code that creates my Contact type Buyers on an order and then their Attorneys.
I can create a Buyer and Attorney just fine.
For some reason when i try to link Attorney to the Buyer i get an error:
"Cannot perform runtime binding on a null reference"
This is part of the code i am using:
dynamic Buyer = ((IOrder)o).CreateNew("Buyer");
dynamic Individual1 = Buyer.Individual1;
Individual1.FirstName = BuyerRow["fname_tx"].ToString();
Individual1.MiddleName = BuyerRow["mname_tx"].ToString();
Individual1.LastName = BuyerRow["lname_tx"].ToString();
dynamic Contacts = o.Contacts;
Contacts.Add(Buyer);
string buyerAQSt = "SELECT * from TESTTBL where [file_party_id]=" + BuyerRow["attorney_file_party_id"];
buyerADt = dbConnectQuery(buyerAQSt);
dynamic Attorney = ((IOrder)o).CreateNew("Attorney");
Attorney.Name = buyerADt.Rows[0]["bus_name_tx"].ToString();
Attorney.Phone = buyerADt.Rows[0]["bphone_tx"].ToString();
Attorney.Fax = buyerADt.Rows[0]["bfax_tx"].ToString();
Attorney.Email = buyerADt.Rows[0]["email_tx"].ToString();
dynamic AddressBA = Attorney.Address;
AddressBA.Address1 = buyerADt.Rows[0]["addr1_tx"].ToString();
AddressBA.Address2 = buyerADt.Rows[0]["addr2_tx"].ToString();
AddressBA.City = buyerADt.Rows[0]["city_tx"].ToString();
string stateCd = buyerADt.Rows[0]["state_cd"].ToString();
IEnum<IState> state = enumMgr.GetEnum<IState>();
AddressBA.State = state.Values.First(t => t.Name == stateCd);
AddressBA.Zip = buyerADt.Rows[0]["zip_tx"].ToString();
IList people = (IList)Attorney.People;
dynamic person = order.CreateNew("Person");
person.FirstName = buyerADt.Rows[0]["fname_tx"].ToString();
person.MiddleName = buyerADt.Rows[0]["mname_tx"].ToString();
person.LastName = buyerADt.Rows[0]["lname_tx"].ToString();
person.Cell = buyerADt.Rows[0]["mphone_tx"].ToString();
people.Add(person);
Contacts.Add(Attorney);
o.Attorneys[0].Represents.Code = "B";
This is the line i am trying to link Attorney to buyer:
"o.Attorneys[0].Represents.Code = "B";
I also tried doing:
dynamic Rep =Attorney.Represents;
Rep.Code="B";
With "B" being the code of the first buyer.
I get the error with both ways.
I tried adding the representation after the order was already created as well, with no luck. Please advise me as to what i am doing wrong.
Thanks
Adding a Attorney Representation
-
- Posts: 18
- Joined: Fri Oct 03, 2008 1:12 pm
Re: Adding a Attorney Representation
To associate the Attorney to the Buyer, you don't want to set the Code, you just want to set the reference to the Buyer object.
So, setting o.Attorneys[0].Represents = Buyer should be all you need to do.
So, setting o.Attorneys[0].Represents = Buyer should be all you need to do.
Joni Hoffman
Software Developer
SoftPro
Software Developer
SoftPro
Re: Adding a Attorney Representation
I am trying to follow along with this older thread but I am not able to set the BUYER or SELLER reference object to the .Represents contact field. NOTE: I know that ContactType.Buyer is not correct but this is the code that I currently have in my attempt to set the ...Represents field. Just using = BUYER does not expose any object like that.
Code: Select all
if (Convert.ToString(dtParty.Rows[iPartyRow].ItemArray[59]).Trim() == "B" || Convert.ToString(dtParty.Rows[iPartyRow].ItemArray[59]).Trim() == "S")
{
string scode = (Convert.ToString(dtParty.Rows[iPartyRow].ItemArray[59]).Trim());
Int32 iobj = 0;
foreach (object obj in ((IList)order["Contacts"]))
{
if (obj.ToString().IndexOf("(" + scode.Trim() + ")") > 0)
{
switch (scode.ToUpper().Trim())
{
case "B":
attorney.Represents = ContactType.Buyer;
break;
case "S":
attorney.Represents = ContactType.Seller;
break;
default:
break;
}
}
iobj += 1;
}
}
Doug Hamilton
CHICAGO TITLE
20825 SWENSON DR SUITE 300 WAUKESHA, WI 53186
P: 262-796-3808 F: 262-796-3888
EMAIL: Doug.Hamilton@fnf.com
www.wi.ctic.com | www.chicagoagent.com | www.etitle.ws
CHICAGO TITLE
20825 SWENSON DR SUITE 300 WAUKESHA, WI 53186
P: 262-796-3808 F: 262-796-3888
EMAIL: Doug.Hamilton@fnf.com
www.wi.ctic.com | www.chicagoagent.com | www.etitle.ws
Re: Adding a Attorney Representation
so nevermind, I have coded the following which is working. I had to code the addition of my contacts so the buyer and seller came before the attorney so there was an object in the order["contacts"] so I could loop through the collection to get the required buyer seller contact.
Code: Select all
if (Convert.ToString(dtParty.Rows[iPartyRow].ItemArray[59]).Trim() == "B" || Convert.ToString(dtParty.Rows[iPartyRow].ItemArray[59]).Trim() == "S")
{
string scode = (Convert.ToString(dtParty.Rows[iPartyRow].ItemArray[59]).Trim());
foreach (IContact obj in ((IList)order["Contacts"]))
{
if (obj.ToString().IndexOf("(" + scode.Trim() + ")") > 0)
{
switch (scode)
{
case "S":
dynamic seller = obj;
attorney.Represents = seller;
break;
case "B":
dynamic buyer = obj;
attorney.Represents = buyer;
break;
}
}
}
}
Doug Hamilton
CHICAGO TITLE
20825 SWENSON DR SUITE 300 WAUKESHA, WI 53186
P: 262-796-3808 F: 262-796-3888
EMAIL: Doug.Hamilton@fnf.com
www.wi.ctic.com | www.chicagoagent.com | www.etitle.ws
CHICAGO TITLE
20825 SWENSON DR SUITE 300 WAUKESHA, WI 53186
P: 262-796-3808 F: 262-796-3888
EMAIL: Doug.Hamilton@fnf.com
www.wi.ctic.com | www.chicagoagent.com | www.etitle.ws
-
- Posts: 1376
- Joined: Wed Jan 15, 2014 3:50 pm
- Location: Raleigh, NC
- Contact:
Re: Adding a Attorney Representation
Glad you got it working!
Bob Richards, Senior Software Developer, SoftPro