You are here: Home / Documentation / 6. Add-ins / 6.6 eWay-CRM API / Work With Relations

Work With Relations

SaveRelation Method

SaveRelation method is used within creation of new relation in eWay-CRM. Method calling and its parameters are described below. There are also described the return values. All available parameters can be found after activation of documentation on your web service.

First we have to define relation that we want to create - we declare a variable in which we will define array with new relation parameters.

$relation = array(
'ItemGUID1' => '182e0c13-ca39-4fbf-9707-d91ef0f33165',
'ItemGUID2' => '9ac9977e-7afc-46b6-b470-6342e78e6a31',
'FolderName1' => 'Contacts',
'FolderName2' => 'Companies',
'RelationType' => 'COMPANY',
'DifferDirection' => '1'
);

Consequently we will use $connector variable for calling the "SaveRelation" method and as a parameter we will pass our variable $relation.

$result = $connector->SaveRelation($relation);

Afterwards we will create simple condition for result verification. In case of successful result we will print information message. Otherwise we will print notification with further information about problem.

if ($result->ReturnCode == 'rcSuccess')
{
print ("New lead created");
}
else
{
print ("Unable to create new lead " . $result->Description);
}

Result will look like below.

In case of failure result, the message will look like below (regarding to the error), for example which parameter need to be changed.