Page 1 of 1

Setting value to the HOA field in Property

Posted: Thu Aug 10, 2023 12:48 pm
by saraponnus
Hi,
How to assign values to the HOA field in the property? If there is only one HOA contact, it is automatically selected however if there are more records then how to select and assign it to this field? I am trying to pick one of those values via overlay code using C#. Please provide a code snippet if possible.

I've tried with help pages but I don't see HOA field information at all. Please help.

Note: I originally created this question under custom order rules but realized this is the right place.
HOA_SPS.JPG
HOA_SPS.JPG (25.22 KiB) Viewed 4133 times

Regards,
Saravanan

Re: Setting value to the HOA field in Property

Posted: Thu Aug 10, 2023 1:17 pm
by vmrvichin
I just responded to your question in the custom order rule forum thinking you were trying to write a custom order rule to manipulate this value.

There are a couple of tools within select to help you find the path to a specific object. One of those is the FieldCode Browser where you can look around the Order model to find the path to a specific to a value. The other is ALT + F6 while you have a field selected, that will give you some clues as to where to find that field within the field code browser.

In your specific case that field is 'Order.Properties[].HOA' and the datatype that it is expecting is one of the specific HOA order contacts from the 'Order.HOAs' list.

Re: Setting value to the HOA field in Property

Posted: Thu Aug 10, 2023 1:30 pm
by saraponnus
Thanks for you response. I've tried to set the value as below but returns error:

IOrderItem hoaContact = iOrder.CreateNew(ContactType.HOA.ToString());
dynamic dContact = hoaContact;
dContact.Name = "Test";
IOrderItem hoa = iOrder.CreateNew("HOA");
property.SetProperty("HOA", dContact);

And the error is:
"The HOA value on Property is invalid."

Could you help?

Re: Setting value to the HOA field in Property

Posted: Thu Aug 10, 2023 2:30 pm
by vmrvichin
I see what you are trying to do there. The easiest way to do this is to leverage dynamics. You only need to create a new contact once. Once you've created a new contact it must be added to the order's list of Contacts (as opposed to the indivual lists of specific contacts) I've updated your code running under the assumption that your 'property' variable has been previously set to the specific property on the order that you are trying to set the HOA value to. and that the 'order' variable is the IOrderItem you got back from the OpenOrder call.




Code: Select all

dynamic dynamicOrder = order;
dynamic property = dynamicOrder.Properties[0];


dynamic hoaContact = order.CreateNew("HOA");
hoaContact.Name = "Test";
property = hoaContact;

Re: Setting value to the HOA field in Property

Posted: Thu Aug 10, 2023 3:00 pm
by vmrvichin
Sorry, I was multitasking and missed the adding of the new HOA contact to the order's Contact list, and the actual setting of the property.HOA field. The corrected code is below.

Code: Select all

dynamic dynamicOrder = order;
dynamic property = dynamicOrder.Properties[0];


dynamic hoaContact = order.CreateNew("HOA");
hoaContact.Name = "Test";
dynamicOrder.Contacts.Add(hoaContact);
property.HOA = hoaContact;

Re: Setting value to the HOA field in Property

Posted: Thu Aug 10, 2023 3:42 pm
by saraponnus
It worked. Thank you for your prompt response.


Regards,
Saravanan