We’ve developed some resources to help you work effectively from home during COVID-19 Click to learn more

How to use ContactEntity.ExtraFields?

Hi, on the ContactEntity there is a property called ExtraFields. (Not to be confused with extrafields in Service)

According to the documentation it looks like this can be used to append some additional data on a Contact.

Has anyone used this property? Any examples on how it is supposed to work?

I tried setting it using CRMScript, but it doesn't seem to do anything.

#setLanguageLevel 3;

NSContactAgent contactAgent;
NSContactEntity c = contactAgent.GetContactEntity(7);

Map e = c.GetExtraFields();
e.insert("MyForeignApp.MyForeignDevice.Hello", "world");
e.insert("Foo", "Bar");
c.SetExtraFields(e);

c = contactAgent.SaveContactEntity(c);

RE: How to use ContactEntity.ExtraFields?

Hi Frode,

This is only picked up for DocumentEntity and AppointmentEntity types.

Best regards.

Av: Tony Yates 11. jan 2018

RE: How to use ContactEntity.ExtraFields?

Hi Tony,

 

I see that there is a new CustomFields property that unifies ExtraFields and UserDefinedFields. Does it mean we can update extra fields for contacts as well now?

 

Thank you

Av: Véronique Borel 28. maj 2020

RE: How to use ContactEntity.ExtraFields?

Hi Véronique,

this CRMScript works in my local 8.5 R14, so it seems like CustomFields can be used to set both Userdefined and Extra-fields at the same time.

#setLanguageLevel 3;

NSContactAgent contactAgent;
NSContactEntity contact = contactAgent.GetContactEntity(2737);
Map customFields;
customFields.insert("x_number", "1234");         //Extrafield, number
customFields.insert("x_text_short", "Hello");    //Extrafield, text
customFields.insert("SuperOffice:10", "World!"); //Userdefined, text
customFields.insert("SuperOffice:12", "2");      //Userdefined, list
contact.SetCustomFields(customFields);

contact = contactAgent.SaveContactEntity(contact);
Av: Frode Lillerud 28. maj 2020

RE: How to use ContactEntity.ExtraFields?

Thanks Frode!

Av: Véronique Borel 28. maj 2020

RE: How to use ContactEntity.ExtraFields?

ExtraFields om contact, person, project, sale can now set foreign keys:

Person.ExtraFields["Fkapp. Device. Device id. Key name" ] = "value"

 

Device id is optional.

You can also get foreign keys on an entity by passing 

/API/v1/contact/123?fk=true

This will add foreign keys to the Extra Fields property

Av: Christian Mogensen 28. maj 2020

RE: How to use ContactEntity.ExtraFields?

Is there any way of doing that in the Archive Providers using WCF and query on it too?

For example: getting all companies where foreign key 'MyKey' equals 'X'

Av: Matthijs Wagemakers 4. jun 2020