Setting value to the HOA field in Property

Discussions related to custom development with Select.
Post Reply
saraponnus
Posts: 5
Joined: Wed Aug 09, 2023 12:26 pm

Setting value to the HOA field in Property

Post 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 3284 times

Regards,
Saravanan
vmrvichin
Posts: 27
Joined: Thu Jul 22, 2021 11:50 am

Re: Setting value to the HOA field in Property

Post 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.
Vlad Mrvichin, Senior Software Developer, Custom Dev, SoftPro
saraponnus
Posts: 5
Joined: Wed Aug 09, 2023 12:26 pm

Re: Setting value to the HOA field in Property

Post 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?
vmrvichin
Posts: 27
Joined: Thu Jul 22, 2021 11:50 am

Re: Setting value to the HOA field in Property

Post 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;
Vlad Mrvichin, Senior Software Developer, Custom Dev, SoftPro
vmrvichin
Posts: 27
Joined: Thu Jul 22, 2021 11:50 am

Re: Setting value to the HOA field in Property

Post 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;
Vlad Mrvichin, Senior Software Developer, Custom Dev, SoftPro
saraponnus
Posts: 5
Joined: Wed Aug 09, 2023 12:26 pm

Re: Setting value to the HOA field in Property

Post by saraponnus »

It worked. Thank you for your prompt response.


Regards,
Saravanan
Post Reply