Skip to main content
    Industry Insights

    Defaulting a service item onto a NetSuite time entry from a project task field

    The Service Item is required in Charge-Based Billing. But what if an employee's service item depends on which task they're booking time to?

    Brian Wenzl
    Brian Wenzl
    The Glue Guy

    One of our clients uses an upstream system for time entry. Time records are created in NetSuite via REST web services. For now, what comes over in the feed comes over in the feed: Employee, Project, Project Task, Duration, Approval Status, Date, External ID.

    As part of implementing an acquired company as a new subsidiary in the instance, we are also working toward introducing Charge-Based Billing. For this, we need Service Items on Time.

    Fortunately, the client’s project management pattern allows for one Service Item per Project Task, so we added a custom field on the task, and used a workflow to set the Service Item as the time comes in over REST.

    The idea was simple, but there was some funny business, which we share below.

    What we did

    1. Created a custom field on Project Task called custevent_ock_service_item — a List/Record reference to the Service Item list.
    2. Populated it on the project tasks in our project templates so the mapping is in place as soon as the Project is created.
    3. Added a Set Field Value action on a Time workflow that reads the project task's custom field and writes it onto the time entry's Service Item field.

    The casetaskevent join doesn't work until after the first record save

    When you build the formula in SuiteFlow, the field picker suggests {casetaskevent.fieldname} — Case/Task/Event is the polymorphic field on the time record, and that's the join name the UI knows about. But the polymorphic join won't resolve a custom field deployed specifically to Project Task, and you'll get a "Field not found" error referencing the project's internal ID as if it were a customer.

    Edit the formula to use {projecttask.fieldname} instead. When the Case/Task/Event on a time entry is a project task, the projecttask join resolves directly to the project task record. You can source fields this way.

    A List/Record field returns the name, not the ID

    If custevent_ock_service_item is a List/Record reference to the Service Item list, then {projecttask.custevent_ock_service_item} returns the display name of the referenced item, e.g., “Agency Fees: Creative," not its internal ID. The Service Item field on the time entry wants an internal ID, so feeding it a name yields an "Invalid item reference key" error.

    Append .id to the reference to get the internal ID:

    case when {projecttask.custevent_ock_service_item} is not null

    then {projecttask.custevent_ock_service_item.id}

    else [defaultvalue]

    end

    Where [defaultvalue] is the internal ID of whatever fallback service item you want applied when the project task's field is empty.

    One More Note

    The time entry doesn’t have access to the Project Task until After Submit, but if the Project uses Charge-Based Billing, a Service Item is required to submit the record. To solve this, we added a Before Load action to the same workflow that sets the Service Item to [defaultvalue] and then we set the Service Item properly in After Submit.