Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Modifying PersonCustomField #67

Open
gregarican opened this issue Sep 30, 2020 · 2 comments
Open

Modifying PersonCustomField #67

gregarican opened this issue Sep 30, 2020 · 2 comments
Labels
question Further information is requested

Comments

@gregarican
Copy link
Contributor

gregarican commented Sep 30, 2020

So I have a routine in my project that is attempting to modify the value of a specific a PersonCustomField. The value associated with the key I need updating is a string, however. Looking at the available functionality, it appears as if I can only set the value to be a numeric datatype. Unless I'm missing something in my logic. Sample code below.

            var personFields = person.CustomFields;
            var personField = new PersonCustomField();
            personField.Value = Convert.ToInt32(armsId);    // Required, although I need to pass my armsId in a string datatype.
            person.CustomFields[armsIdFieldKey] = personField;

Any suggestions as to how I best handle this? Ultimately it would be best if I could define the datatype when I am initializing the new PersonCustomField. But I didn't see how to do this.

@gregarican
Copy link
Contributor Author

I think I see now. I need to change my code to this, correct?

var personField = new StringCustomField(armsId); person.CustomFields[armsIdFieldKey] = personField;

@DavidRouyer DavidRouyer added the question Further information is requested label Sep 30, 2020
@DavidRouyer
Copy link
Owner

When you want to update a custom field which is a person or an organization, you have to pass the ID when you want to update it. See the example below:

var testDeal = await client.Deal.Get(1);
var personField = testDeal.CustomFields["hashOfMyCustomField"]; // null or PersonCustomField

var dealToUpdate = testDeal.ToUpdate();

dealToUpdate.CustomFields["hashOfMyCustomField"] = new LongCustomField(627);

await client.Deal.Edit(testDeal.Id, dealToUpdate);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants