Promotion Code

Promotions enable you to track the source of revenue and to offer discounts in the form of coupons. Each promotion has a promotion code that can be applied to transactions and campaigns.

The promotion code record is defined in the listMkt (marketing) XSD.

For information about working with this record in the UI, see Selling with Promotion Codes.

Supported Operations

The following operations can be used with promotion code records:

add | addList | delete | deleteList | get | getDeleted | getList | getSavedSearch | getSelectValue | search | update | updateList | upsert | upsertList

Note:

You can also use the asynchronous equivalents of SOAP web services list operations. For information about asynchronous operations, see SOAP Web Services Asynchronous Operations. For more information about request processing, see Synchronous Versus Asynchronous Request Processing.

Field Definitions

The SOAP Schema Browser includes definitions for all body fields, sublist fields, search filters, and search joins available to this record. For details, see the SOAP Schema Browser’s promotion code reference page.

Note:

For information about using the SOAP Schema Browser, see SOAP Schema Browser.

Usage Notes

Warning:

Line discount promotions are not compatible with 2009.2 and earlier endpoints. If you want to use these with SOAP web services, you must upgrade to the 2010.1 or later endpoint.

Code Sample

The following sample shows how to add a promotion code record to NetSuite.

Java

          public void addPromotionCode()throws RemoteException
   {
      //This operation requires a valid session
      this.login(true);
      
      String readStr = "";
      PromotionCode pc = new PromotionCode();
 
      _console.writeLn("\nPlease enter promotion name: ");
      readStr = _console.readLn();
      pc.setCode(readStr);
      
      _console.writeLn("\nPlease enter description : ");
      readStr = _console.readLn();
      pc.setDescription(readStr);
      
      pc.setIsInactive(new Boolean(false));
      
      _console.writeLn("\nPlease enter the discount item internal ID: ");
      readStr = _console.readLn();
      RecordRef discount = new RecordRef();
      discount.setType(RecordType.discountItem);
      discount.setInternalId(readStr);
      pc.setDiscount(discount);
      
      //pc.setRate(String rate) //required if discount item not specified
      //pc.setDiscountType(Boolean discountType) //required if discount item not specified
      _console.writeLn("Do you want to apply code to first sale only or all sales?");
      
      while(true)
      {
         _console.writeLn("\nEnter 1 for First Sale Only, 2 for All Sales.");
         readStr = _console.readLn();
         PromotionCodeApplyDiscountTo applyDiscountTo = null;
         
         if(readStr.equalsIgnoreCase("1"))
         {
            applyDiscountTo = PromotionCodeApplyDiscountTo._firstSaleOnly;
            pc.setApplyDiscountTo(applyDiscountTo);
            break;
         }
         if(readStr.equalsIgnoreCase("2"))
         {
            applyDiscountTo = PromotionCodeApplyDiscountTo._allSales;
            pc.setApplyDiscountTo(applyDiscountTo);
            break;
         }
      }
      
      Calendar startDate = Calendar.getInstance();
      Calendar endDate = Calendar.getInstance();
      
      _console.writeLn("Enter promotion code starting day.");
      readStr = _console.readLn();
      int day = Integer.parseInt(readStr);
      
      _console.writeLn("Enter promotion code starting month (1-12).");
      readStr = _console.readLn();
      int month = Integer.parseInt(readStr);
      
      //January=0
      startDate.set(2009, month-1, day);
      pc.setStartDate(startDate);
      
      _console.writeLn("Enter promotion code ending day.");
      readStr = _console.readLn();
      day = Integer.parseInt(readStr);
      
      _console.writeLn("Enter promotion code ending month (1-12).");
      readStr = _console.readLn();
      month = Integer.parseInt(readStr);
 
      endDate.set(2009, month-1, day);
                pc.setEndDate(endDate);
      
      pc.setIsPublic(new Boolean(true));
      pc.setExcludeItems(new Boolean(false));   
      
      WriteResponse writeRes = _port.add(pc);
      boolean success = writeRes.getStatus().isIsSuccess();
      if (success) 
      {
         _console.writeLn("\nPromotion Code created successfully.");
         RecordRef _ref = (RecordRef)(writeRes.getBaseRef());
         _console.writeLn("Internal ID: " + _ref.getInternalId());
      } 
      else 
      {
         _console.error(getStatusDetails(writeRes.getStatus()));
      }   
   } 

        

SOAP Request

          <soapenv:Body>
      <platformMsgs:add
          xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"
          xmlns:listMktTyp="urn:types.marketing_2017_1.lists.webservices.netsuite.com"
          xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
          xmlns:platformMsgs="urn:messages_2017_1.platform.webservices.netsuite.com"
          xmlns:platformCore="urn:core_2017_1.platform.webservices.netsuite.com"
          xmlns:xs="http://www.w3.org/2001/XMLSchema"
          xmlns:s0="urn:marketing_2017_1.lists.webservices.netsuite.com"
          xmlns:s1="urn:sales_2017_1.transactions.webservices.netsuite.com">
         <platformMsgs:record xsi:type="s0:PromotionCode">
            <s0:code>Any Promo Code</s0:code>
            <s0:isInactive>false</s0:isInactive>
            <s0:discount internalId="28" />
            <s0:applyDiscountTo>_firstSaleOnly</s0:applyDiscountTo>
            <s0:startDate>2009-01-09T23:23:38.787Z</s0:startDate>
            <s0:endDate>2009-01-16T18:23:52.000Z</s0:endDate>
            <s0:isPublic>true</s0:isPublic>
            <s0:excludeItems>false</s0:excludeItems>
         </platformMsgs:record>
      </platformMsgs:add>
   </soapenv:Body>
</soapenv:Envelope> 

        

Related Topics

General Notices