0
votes

Is there any way to update multiple fields for an object in Dynamics CRM 2011 using java. All I am able to do now is to update one field for an object (ContactSet,AccountSet etc..)

URL : https://xxxxxx.xxxx.xx/xxxxxx/XrmServices/2011/OrganizationData.svc/ContactSet(guid'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx')

What I have done?

    Map<String,Object> update = Maps.newHashMap();
    update.put("FirstName","xxxxx");
    update.put("LastName","xxxxx");
    update.put("Telephone1","xxxxxxxx");


    ObjectMapper mMapper = new ObjectMapper();

    mEntity = mMapper.writeValueAsString(update);

    String mUrl = this.url+"/"+getObject()+"(guid'"+id+"')";

    HttpPut httpPut = new HttpPut(mUrl);
    httpPut.setHeader("Content-Type", "application/json");
    httpPut.setHeader("Accept","application/json");
    httpPut.setEntity(new StringEntity(mEntity,"UTF-8"));

    HttpResponse response = this.client.execute(httpPut);

The above code always gives a 500 internal server error. What works?

    Map<String,Object> update = Maps.newHashMap();
    update.put("FirstName","xxxxx");
    mEntity = mMapper.writeValueAsString(update);

    String mUrl = this.url+"/"+getObject()+"(guid'"+id+"')"+"/FirstName";
    HttpPut httpPut = new HttpPut(mUrl);
    httpPut.setHeader("Content-Type", "application/json");
    httpPut.setHeader("Accept","application/json");
    httpPut.setEntity(new StringEntity(mEntity,"UTF-8"));

    HttpResponse response = this.client.execute(httpPut);

I don't see a point in updating just a single field. Can someone please give pointers on how to update multiple fields?

1

1 Answers

0
votes

I would recommend you to use javascript and Jquery or if you prefer java try to follow the microsoft code Javascript example.

It is possible to update multiple columns, just check your code syntax.