Search code examples
phpwsdlsugarcrm

Update a row through SugarCRM WSDL


I have the documentation PDF for the version a client is running (I believe 3.1 Pro but am not 100% sure; that may just be the version initially purchased) but I cannot quite figure out how to UPDATE records. Here is what I know so far:

set_entry seems to be the closest match. I see from the PDF that the following is true about this function:

"Creates or updates a SugarBean"

How do I tell it to update rather than insert a record? For example, I am trying to update one column of one table to one specific value and I think I am as close as I can get with the following:

$result = $sugar['soapclient']->call(
    'set_entry',
    array(
        'session'=>$sugar['session'],
        'module_name'=>'Kits',
        array(
            array("name" => 'location', "value" => 'New Cool Location')
        ),
        'where'=>'id="1000ee55-55dc-feb0-c71a-4e5e8c31ad1b"'
    )
);

Clarification: I want to update the column 'location' to 'New Cool Location' only where the 'id' is '1000ee55-55dc-feb0-c71a-4e5e8c31ad1b'. I have also not ran this code on the live environment yet because we lack a fully functional development environment, so I want to be more confident in the code before it is ran.


Solution

  • Change the code example as following:

    $result = $sugar['soapclient']->call(
    'set_entry',
    array(
        'session'=>$sugar['session'],
        'module_name'=>'Kits',
        array(
            array("name" => 'location', "value" => 'New Cool Location')
            array("name" => 'id', "value" => '1000ee55-55dc-feb0-c71a-4e5e8c31ad1b')
        ),
    )
    );