Error when trying to add property to collections

Discussions concerning general integration topics.

Moderator: Phil Barton

Post Reply
Rakesh
Posts: 1
Joined: Thu Sep 28, 2017 6:03 am

Error when trying to add property to collections

Post by Rakesh »

When we try to add properties to propeties collection we are getting the below error.

Code:
dynamic property = newOrder.CreateNew("Property");
dynamic address = property.Address;
property.EscrowBriefLegal = prop.EscrowBriefLegal;
if (address.UseForeignAddress)
{
address.UseForeignAddress = false;
}
address.Address1 = prop.Address.Address1;
address.Address2 = prop.Address.Address2;
address.City = prop.Address.City;
address.Zip = prop.Address.Zip;

address.State = GetState(prop.Address.StateGLC, selectServer);

address.County = prop.Address.County;
dynamic properties = order.Properties;
properties.Add(property);

Error:
Cannot implicitly convert type 'void' to 'object'

at CallSite.Target(Closure , CallSite , Object , Object )
at System.Dynamic.UpdateDelegates.UpdateAndExecute2[T0,T1,TRet](CallSite site, T0 arg0, T1 arg1)

We are getting the same error with contacts and lender also.
BobRichards
Posts: 1377
Joined: Wed Jan 15, 2014 3:50 pm
Location: Raleigh, NC
Contact:

Re: Error when trying to add property to collections

Post by BobRichards »

In order to add to order collection properties like Addresses, Contacts, etc. you need to cast the collection to a list. Also remember to add the new item to the order model as quickly as possible so all order rules run properly. Here is an example of adding a new address to an order:

Code: Select all

// Create new Address and add it to order.
IList addresses = (IList)order.GetProperty("Properties");
dynamic property = order.CreateNew("Property")
address.Add(property);

// Modify address object.
property.EscrowBriefLegal = prop.EscrowBriefLegal;
...
Bob Richards, Senior Software Developer, SoftPro
Post Reply