Adding a Project with a Status Example One

The following example shows how to add a new project record that has a specific status.

Java

          public void addJob() throws RemoteException, ExceededRecordCountFault,
        ExceededUsageLimitFault, InsufficientPermissionFault,
        InvalidSessionFault {
                // This operation requires a valid session
                this.login(true);
                
                Job job = new Job();
                
                job.setEntityId("XYZ Inc");
                job.setCompanyName("Scripting requirements");
 
                // Set entity status. The nsKey can be obtained from Setup > Accounting > Accounting List
                // Job Status.
                RecordRef status = new RecordRef();
                // 1 = Closed, 2 = In Progress, 3 = Not Awarded, 4 = Pending, 5 = Awarded
                status.setInternalId("4");
                
                job.setEntityStatus(status);
                                
                // Invoke add() operation
                WriteResponse response = _port.add(job);
                
                // Print the document id from the SOAP header
                // _console.info(
                // "\nThe add() operation with document id " + _port.documentInfo.nsID +
                // " was processed " );
                
                // Process the response
                if (response.getStatus().isIsSuccess()) {
                        _console.info("\nThe following job was added successfully:"
                        + "\nkey="
                        + ((RecordRef) response.getBaseRef()).getInternalId()
                        + "\nentityId="
                        + job.getEntityId()
                        + "\ncompanyName="
                        + job.getCompanyName()
                        + "\nstatusKey="
                        + job.getEntityStatus().getInternalId());
                } else {
                        _console.error("The job was not added:", true);
                        _console.error(getStatusDetails(response.getStatus()));
                }
        } 

        

SOAP Request

          <soapenv:Body>
      <add xmlns="urn:messages_2017_1.platform.webservices.netsuite.com">
         <record xsi:type="ns6:Job" xmlns:ns6="urn:relationships_2017_1.lists.webservices.netsuite.com">
            <ns6:entityId xsi:type="xsd:string">XYZ Inc</ns6:entityId>
            <ns6:companyName xsi:type="xsd:string">Scripting requirements</ns6:companyName>
            <ns6:entityStatus internalId="4" xsi:type="ns7:RecordRef"
              xmlns:ns7="urn:core_2017_1.platform.webservices.netsuite.com" />
         </record>
      </add>
   </soapenv:Body> 

        

SOAP Response

           <soapenv:Body>
      <addResponse xmlns="urn:messages_2017_1.platform.webservices.netsuite.com">
         <writeResponse>
            <ns2:status isSuccess="true" xmlns:ns2="urn:core_2017_1.platform.webservices.netsuite.com" />
            <baseRef internalId="165" type="job" xsi:type="ns3:RecordRef"
              xmlns:ns3="urn:core_2017_1.platform.webservices.netsuite.com" />
         </writeResponse>
      </addResponse>
   </soapenv:Body> 

        

Related Topics

General Notices