UPDATE A FIELD IN ACCOUNTS USING REST API WITHOUT USING ACCOUNT ID

Hi

    

I want to update a record in Account module with the REST API.

Currently i am following

       http://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_7.6/API/Web_Services/Examples/v10/module_record_PUT/

Here i was able to update the record based on the account id using

CROP.pngShijin Krishna@

In my crm i am having a field account_number in Accounts module which is unique for each Account.

I want to use this to update fields in my Account using REST API instead of the account id.

Parents
  • Hi Anand,

    Just changing the $record_arguments array in the example like below should do your job.

    $record_arguments = array(
       "account_number" => "{YOUR_UNIQUE_ACCOUNT_NUMBER}",
    );

     

    Hope it helps!

    -Shijin Krishna

  • Hi Shijin Krishna

        Thank You for your reply.It worked for me as you said when i have mentioned the account id of the record in

    $url = $base_url . "/Accounts860d4d45-2e5a-e211-a5bb-560cf4c7efa3/";

    Actually i wanted this to update the record without passing the account id(860d4d45-2e5a-e211-a5bb-560cf4c7efa3) to variable $url as i dont have access to retreive the account id.

    I have finally got this by using the filter api and retreiving the account id of the record based on the account number.Then i have passed account id to $url and updated other field in the account.

    $filter_arguments = array(

        "filter" => array(

        array(

            'acc_no_c' => 'XXXXXXXX',

        ),

                        ),

    );

    $url = $base_url . "/Accounts/filter";

    $filter_response = call($url, $oauth2_token_response->access_token, 'POST', $filter_arguments);//$filter_response has the account id here and passed it to the $url later and then updated the other fields in the record as per the update api.

Reply
  • Hi Shijin Krishna

        Thank You for your reply.It worked for me as you said when i have mentioned the account id of the record in

    $url = $base_url . "/Accounts860d4d45-2e5a-e211-a5bb-560cf4c7efa3/";

    Actually i wanted this to update the record without passing the account id(860d4d45-2e5a-e211-a5bb-560cf4c7efa3) to variable $url as i dont have access to retreive the account id.

    I have finally got this by using the filter api and retreiving the account id of the record based on the account number.Then i have passed account id to $url and updated other field in the account.

    $filter_arguments = array(

        "filter" => array(

        array(

            'acc_no_c' => 'XXXXXXXX',

        ),

                        ),

    );

    $url = $base_url . "/Accounts/filter";

    $filter_response = call($url, $oauth2_token_response->access_token, 'POST', $filter_arguments);//$filter_response has the account id here and passed it to the $url later and then updated the other fields in the record as per the update api.

Children