Post

2 followers Follow
0
Avatar

Update a custom field with REST API

Hi,

I would like to update a custom field in Clarizen using Rest api using Javascript section of custom panel.

In my custom panel I've a HTML table. This table shows the content of several Custom Fields that are in clarizen (let's take as example "C_ValidatedTotalCost"). 
I've made the table editable and I would like to know how I can update the custom field using the API. I assume it's the only way I can achieve this.

So when user enter a new value in a td of the table, then the corresponding Custom field should be updated.

Could you please provide me a code example to achieve this ? https://api.clarizen.com/V2.0/services/ is no help for me at the moment.

Of course if you know a different way to achieve this, I'm listening !

Thank you, 
Regards

Steve Bekaert Answered

Official comment

Avatar

Hi Steve,

Did you find the solution for this issue?

If not, I will test it and let you know how you should perform the update.

 

Elad Franklin
Comment actions Permalink

Please sign in to leave a comment.

4 comments

0
Avatar

Hi Elad,

It's a succes in getting the data but I'm a bit lost for updating that data :

var ID = API.Context.getData().CUser.EXternalID;

var PMP = 'Select Manager from Project WHERE ProjectManager = '/User/"+ID+"'"; 'Where PMP stands for "Projet Manager's Projets"

API.Objects.query(PMP,function(qResults) {

if(qResults != null && qResults.length > 0) {

qResults.forEach(function(jt) {console.log(jt) );

}

});

 

It displays me the result in the console. However I've no idea how can I can perform it to update something in a Custom field in Clarizen. This looks to be the basic of basics... If you have any example, I'll be able to manage it. Note that I'm currently telling myself I shouldn't touch that as I'm lacking the basic knowledge !

 

 

 

Steve Bekaert 0 votes
Comment actions Permalink
0
Avatar

Hi Steve,

You can update the customer filed (or any other field) using this syntax:


API.Server.post("/data/objects/[EntityName]/[Entity external Id]",{[Field name]: [value]})

for example, I am updating a project (id: 5q86yn1ai9ebvedo5eemuvfnf1) and set the C_ValidatedTotalCost value to 30:

API.Server.post("/data/objects/Project/5q86yn1ai9ebvedo5eemuvfnf1",{C_ValidatedTotalCost: 30})

 

I hope this helps,

Elad

Elad Franklin 0 votes
Comment actions Permalink