You're almost there! Please answer a few more questions for access to the Applications content. Complete registration
Interested in joining? Complete your registration by providing Areas of Interest here. Register

Update custom field Add-in

Accepted answer
13
Views
5
Comments
edited Aug 13, 2018 7:27PM in Integrations and APIs 5 comments

Content

Hi all!

I not getting the custom fields via C#. I need update a custom field via Add-in.
How can I do?

My field:
Name: "incident.c$enderco"
Label: "Endereço do chamado"
Type: "text field"
Id: 16

I tried with the followiong code:

Code Snippet

             var incident = ((IIncident)_recordContext.GetWorkspaceRecord(WorkspaceRecordType.Incident));

  OptListID CustomFieldOptListID = OptListID.CustomFields;
  IList<IOptlistItem> OptList = _globalContext.GetOptlist((int)CustomFieldOptListID);

  IList<ICfVal> incidentCustomFields = incident.CustomField;

  foreach (IOptlistItem oli in OptList) {
    if (oli.Label == "endereco") {
      foreach (ICfVal val in incidentCustomFields) {
        if (val.CfId == oli.ID) {
          val.ValStr = "valueField";
          break;
        }
      }
      break;
    }
  } 
        

Howdy, Stranger!

Log In

To view full details, sign in.

Register

Don't have an account? Click here to get started!