Click or drag to resize
Infosoft Logo

Examples

This topic contains the following sections:

This article contains examples of possible uses of the customer relation feature. Before reading this you may want to read the main customer relation article.

External Reference Type Example

A typical example of an external reference type would be a link to an account on an external website, such as Facebook or Twitter. We'll assume the existence of a relation type called "FACEBOOK", defined as follows:

  • Code: "FACEBOOK"

  • ReferenceType: External

  • TitleMode: Forbidden

The TitleMode is Forbidden because any customer will presumably have the same Facebook account regardless of what title they're subscribed to, and the ReferenceType of External means that any reference value will be accepted. The reference should in this case be a valid Facebook account ID, but there will be no validation of this.

We'll assume that there's a customer with the customer number 1000. In order to create a Facebook relation for this customer, we would send the following request:

ICustomerRelationService service = new CustomerRelationServiceClient();
service.CreateCustomerRelation(new CustomerRelationRequest()
{
    CustomerNumber = 1000,
    RelationTypeCode = "FACEBOOK",
    Reference = "20531316728",
    Source = "INFOSOFT EXAMPLES",
});
Customer Reference Type Examples

Since customers usually represent people, an example of a customer reference type could be to indicate arbitrary family/friend relations between different customers in the database. The AdditionalValue field can be used to indicate the type of relation. We'll assume a relation type with the following values:

  • Code: PERSONAL

  • ReferenceType: Customer

  • TitleMode: Forbidden

Now we'll assume that we have the customers Jane Doe (1000) and John Doe (1001), and we want to mark them as being siblings in the database:

ICustomerRelationService service = new CustomerRelationServiceClient();
service.CreateCustomerRelation(new CustomerRelationRequest()
{
    CustomerRelation = new CustomerRelationExchange()
    {
        CustomerNumber = 1000,
        RelationTypeCode = "PERSONAL",
        Reference = "1001",
        AdditionalValue = "SISTER",
        Source = "INFOSOFT EXAMPLES"
    }
});

In this particular case it should be equally correct to create a relation that points in the opposite direction, i.e. with CustomerNumber=1001 and Reference="1000" (and AdditionalValue="BROTHER" presumably), but this may not be the case for all personal relations.

Subscription Reference Type Examples

A relation type with the reference type Subscription works the same way as one with the Customer reference type, except for the additional requirement that the related customer must have a subscription on the given title. Subscription relation types should therefore always have the title mode Required.

A good example of a subscription relation type could be as a way to implement contact person functionality for subscribers. We'll assume we have the customer Joe Smith with the customer number 2000, who is not necessarily a subscriber. We also have a company customer called Contoso Ltd. with the customer number 3000, with a subscription on the title TEST. Now we want to mark Joe Smith as being the contact person of Contoso Ltd. using a customer relation. We'll use the following relation type:

  • Code: CONTACTPERSON

  • ReferenceType: Subscription

  • TitleMode: Required

This is the request we would send to create the customer relation:

ICustomerRelationService service = new CustomerRelationServiceClient();
service.CreateCustomerRelation(new CustomerRelationRequest()
{
    CustomerRelation = new CustomerRelationExchange()
    {
        CustomerNumber = 2000,
        TitleCode = "TEST",
        RelationTypeCode = "CONTACTPERSON",
        Reference = "3000",
        Source = "INFOSOFT EXAMPLES"
    }
});
User Reference Type Examples

The User ReferenceType is only applicable when using the User Register. The main reason to use a User reference instead of a Customer reference is when you want to be able to connect customers to people whose data is stored in the User Register, but who aren't necessarily customers with address information.

We currently don't have any real-life examples of the User reference type. Please contact Infosoft if you would like information about how to use this reference type.

Customer Relation Retrieval Example

There is currently only a single method for retrieving customer relations: GetCustomerRelationsByCustomer. In order to use this, simply give the customer number of the customer whose relations you would like to retrieve. Using data from some of the other examples above, here's an example of how to call the method and the output you can expect:

GetCustomerRelationsByCustomer Input
ICustomerRelationService service = new CustomerRelationServiceClient();
CustomerRelationsResponse response = service.GetCustomerRelationsByCustomer(new GetCustomerRelationsByCustomerRequest()
{
    CustomerNumber = 1000,
});

IList<CustomerRelationExchange> customerRelations = response.CustomerRelations;

Here is an example of the kind of SOAP output you'll get:

GetCustomerRelationsByCustomer Output
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
   <s:Body>
      <CustomerRelationsResponse xmlns="http://tech.infosoft.no/schemas/2012/08">
         <CustomerRelations xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
            <CustomerRelationExchange>
               <CustomerRelationId>1</CustomerRelationId>
               <CustomerNumber>1000</CustomerNumber>
               <TitleCode i:nil="true"/>
               <RelationTypeCode>FACEBOOK</RelationTypeCode>
               <Reference>20531316728</Reference>
               <AdditionalValue i:nil="true"/>
               <Source>INFOSOFT EXAMPLES</Source>
               <Audit z:Id="i1" xmlns:z="http://schemas.microsoft.com/2003/10/Serialization/">
                  <CreatedBy>INFO</CreatedBy>
                  <CreatedDate>2014-07-17T10:00:00</CreatedDate>
                  <LastChangedBy>INFO</LastChangedBy>
                  <LastChangedDate>2014-07-17T10:00:00</LastChangedDate>
               </Audit>
            </CustomerRelationExchange>
            <CustomerRelationExchange>
               <CustomerRelationId>2</CustomerRelationId>
               <CustomerNumber>1000</CustomerNumber>
               <TitleCode i:nil="true"/>
               <RelationTypeCode>PERSONAL</RelationTypeCode>
               <Reference>1001</Reference>
               <AdditionalValue>SISTER</AdditionalValue>
               <Source>INFOSOFT EXAMPLES</Source>
               <Audit z:Id="i2" xmlns:z="http://schemas.microsoft.com/2003/10/Serialization/">
                  <CreatedBy>INFO</CreatedBy>
                  <CreatedDate>2014-07-17T11:00:00</CreatedDate>
                  <LastChangedBy>INFO</LastChangedBy>
                  <LastChangedDate>2014-07-17T11:00:00</LastChangedDate>
               </Audit>
            </CustomerRelationExchange>
            <CustomerRelationExchange>
               <CustomerRelationId>3</CustomerRelationId>
               <CustomerNumber>1000</CustomerNumber>
               <TitleCode>IT</TitleCode>
               <RelationTypeCode>CONTACTPERSON</RelationTypeCode>
               <Reference>2000</Reference>
               <AdditionalValue i:nil="true"/>
               <Source>INFOSOFT EXAMPLES</Source>
               <Audit z:Id="i3" xmlns:z="http://schemas.microsoft.com/2003/10/Serialization/">
                  <CreatedBy>INFO</CreatedBy>
                  <CreatedDate>2014-07-17T12:00:00</CreatedDate>
                  <LastChangedBy>INFO</LastChangedBy>
                  <LastChangedDate>2014-07-17T12:00:00</LastChangedDate>
               </Audit>
            </CustomerRelationExchange>
         </CustomerRelations>
      </CustomerRelationsResponse>
   </s:Body>
</s:Envelope>
Customer Relation Deletion Example

In order to delete a customer relation you need to know its unique ID, which can be seen in each object in the output from GetCustomerRelationsByCustomer. Assuming there's a customer relation with CustomerRelationId=1, this is how you would delete that relation object:

DeleteCustomerRelation Input
ICustomerRelationService service = new CustomerRelationServiceClient();
service.DeleteCustomerRelation(new DeleteCustomerRelationRequest()
{
    CustomerRelationId = 1,
});

If the deletion was successful, a response containing the now deleted object is returned:

DeleteCustomerRelation Output
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
  <s:Body>
    <CustomerRelationResponse xmlns="http://tech.infosoft.no/schemas/2012/08">
      <CustomerRelation xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
        <CustomerRelationId>1</CustomerRelationId>
        <CustomerNumber>1000</CustomerNumber>
        <TitleCode i:nil:"true"/>
        <RelationTypeCode>FACEBOOK</RelationTypeCode>
        <Reference>20531316728</Reference>
        <AdditionalValue i:nil="true"/>
        <Source i:nil="true"/>
        <Audit z:Id="i1" xmlns:z="http://schemas.microsoft.com/2003/10/Serialization/">
          <CreatedBy>INFO</CreatedBy>
          <CreatedDate>2014-07-17T10:00:00</CreatedDate>
          <LastChangedBy>INFO</LastChangedBy>
          <LastChangedDate>2014-07-17T10:00:00</LastChangedDate>
        </Audit>
      </CustomerRelation>
    </CustomerRelationResponse>
  </s:Body>
</s:Envelope>
See Also