Post

2 followers Follow
0
Avatar

Controlling the State field when creating timesheets via api

Hello,

Recently Ive been using the api to import timesheet data. Generally this is all working creating timesheets with for a given user, work item, reported date and duration with Createmessage.

Up to now when I have created timesheets they have had the default state of Un-submitted and Ive used a workflow rule to bump them to approved. However now Id like to set them Approved from within the API. 

Does anyone know how to correctly format the commands to set the State field of the timesheet entity to the Approved value of the state picklist? (up to now Ive not worked with picklists/ lifecycle fields with the api)

Do I need to use LifecycleMessage? There is mention of it in the Web servics guide but no examples that I can see.

Thanks!

Import from old forum Answered

Please sign in to leave a comment.

1 comment

0
Avatar

Correct. You have to use the LifeCycleMessage to change the state of a Timesheet.

The following XMLs shows how to move an item to state Submitted and Approved:

<?xml version="1.0" encoding="utf-8"?>

<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">

  soap:Header

    <Session xmlns="http://clarizen.com/api">

      <ID>XXX</ID>

    </Session>

  /soap:Header

  soap:Body

    <Execute xmlns="http://clarizen.com/api">

      <request>

        <BaseMessage xsi:type="LifecycleMessage">

          <Ids>

            <EntityId>

              <TypeName>Timesheet</TypeName>

              <Value>8a676b1c-5f22-475b-8c1c-375766609140</Value>

            </EntityId>

          </Ids>

          <Operation>Submit</Operation>

          <Recursive>false</Recursive>

        </BaseMessage>

      </request>

    </Execute>

  /soap:Body

/soap:Envelope

Approve:

<?xml version="1.0" encoding="utf-8"?>

<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">

  soap:Header

    <Session xmlns="http://clarizen.com/api">

      <ID>XXX</ID>

    </Session>

  /soap:Header

  soap:Body

    <Execute xmlns="http://clarizen.com/api">

      <request>

        <BaseMessage xsi:type="LifecycleMessage">

          <Ids>

            <EntityId>

              <TypeName>Timesheet</TypeName>

              <Value>8a676b1c-5f22-475b-8c1c-375766609140</Value>

            </EntityId>

          </Ids>

          <Operation>Approve</Operation>

          <Recursive>false</Recursive>

        </BaseMessage>

      </request>

    </Execute>

  /soap:Body

/soap:Envelope

Clarizen Team 0 votes
Comment actions Permalink