Coming soon: Your brand new Help Center & Community! Get a sneak-peek here

Using udefhelper when Contact has no userdef_id

Hi,

We're using UdefHelper to set user defined fields on contacts (copy from the SDK) :

contact.UdefHelper["SuperOffice:3"] = 1234;
contact.Save();

This is well documented and works fine if a userdefined field is already present on the contact. But a new contact does not have a userdef_id or a record in UDContactsmall/large. 

Is there a way to create that record, so it can be updated via the method above?

Thanks.

RE: Using udefhelper when Contact has no userdef_id

Ehm.. a.f.a.i.k. the Win COM API does not expose a UdefHelper on the Contact interface but a UDef property as an IUDefFields interface.

Are you by any change in the Netserver Entities world?
If so, you might get a better answer in the Netserver forum...

That said, you might be seeing an issue we encovered recently with the Helper classes in the Entities. This is fixed in the next release...

(forcing a parent field change, to make it dirty, might be a work-around).
Conrad

Af: Conrad Weyns 7. maj 2017

RE: Using udefhelper when Contact has no userdef_id

Hi Conrad, 

Thank you for the quick reply and input.

I managed to make this workaround :

UDContactSmallRow row = UDContactSmallRow.CreateNew();

row.SetDefaults();
row.Long07 = 123; //some value here to make sure the row is actually created.
row.Save();
contactThroughIdx.Row.UserdefId = row.UdcontactSmallId; // <--- put the ID on the contact

 

I don't know SuperOffice well enough to know how "dirty" this is, but at least I still let the system assign the ids. Comments?

Af: Stig Meyer Jensen 7. maj 2017