Property Use

Discussions related to order tracking development with the ProForm module.

Moderator: Phil Barton

Post Reply
shawnregan
Posts: 22
Joined: Tue Dec 11, 2018 10:03 am

Property Use

Post by shawnregan »

I have been looking at how to populate the field “Property Use”, but I can’t locate it in the SDK help. Can you point me in the right direction?
BobRichards
Posts: 1376
Joined: Wed Jan 15, 2014 3:50 pm
Location: Raleigh, NC
Contact:

Re: Property Use

Post by BobRichards »

Step 1: Use the Field Code Browser (or press Alt+F6 with the cursor in the field box), to determine the data type. When you do, you will see its type is IPropertyUse. This type (as well as ANY dynamic type defined in the SPAdmin Drop-down Lists) inherits from IEnumValue. You can see the out-of-the-box types that also inherit from it by entering "IEnumValue" in the SDK Search box. Be aware that drop-down lists can be edited and new ones can be created - so the SDK may not have all of them - but they all work the same way.

Step 2: We now know the type (IPropertyUse). The code below shows how to set the property.

Code: Select all

/// <summary>
/// Get the IPropertyUse IEnum and set the first property to the "1 - 4 family residential" value.
/// </summary>
/// <param name="package">The package.</param>
/// <param name="order">The order.</param>
/// <exception cref="NotSupportedException">Description not found!</exception>
public Dev_IEnumValue(Package package, IOrder order)
{
    // Get the desired dynamic enumeration (IPropertyUse) from the Server.
    SelectServer ss = (SelectServer)package.GetService(typeof(SelectServer));
    IEnumManager enumMgr = (IEnumManager)ss.GetService(typeof(IEnumManager));
    IEnum<IPropertyUse> puEnum = enumMgr.GetEnum<IPropertyUse>();

    // Search for value from dynamic enumeration.
    IPropertyUse pu 
        = puEnum.Values.Where(t => t.Description == "1 - 4 family residential" && t.Enabled).FirstOrDefault();
    if (pu == null)
    {
        throw new NotSupportedException("Description not found!");
    }

    // Set order model property on first Property.
    IList props = (IList)order["Properties"];
    IOrderItem prop0 = (IOrderItem)props[0];
    prop0.SetProperty("Use", pu);
}
Best Practice: You should search always search on the Description field. Never make assumptions about index or code integer value.
Bob Richards, Senior Software Developer, SoftPro
shawnregan
Posts: 22
Joined: Tue Dec 11, 2018 10:03 am

Re: Property Use

Post by shawnregan »

Great, thanks for the info.
Post Reply