Expand my Community achievements bar.

SOLVED

Delete Hours Entries from Billing Records using API module

Avatar

Level 10

Hi Fusion Community,

 

I'd like to bulk remove/delete hours entries from a number of open billing records.  It looks like I would need to use the DELETE method via an API module in Fusion.  Is anyone willing to guide me through this?

 

Thanks!
Nick

 

Topics

Topics help categorize Community content and increase your ability to discover relevant content.

1 Accepted Solution

Avatar

Correct answer by
Level 6

I think you have to use the Custom API Call module (at least, that's how we do it).  Here's an example pipeline that gets to just the deletion portion.  Note that it's simply about setting the hours value to an empty array.

Screen Shot 2023-09-20 at 12.02.43 PM.png

View solution in original post

8 Replies

Avatar

Level 6

It's pretty straightforward.  You can either use the Delete module or the Custom API module with a method of DELETE and a URL of bill/{id}.  Just make sure the billing record first has no hours associated to it and it's not in "invoiced" status.  So you may need to do some updates to the record PRIOR to the deletion itself.

Router

--> Change status to uninvoiced

--> Remove association to any hours

--> Delete the object

 

The removal of association to hours is the trickiest part, but it's just a bill/{id} update call where you set the hours to an empty array / null.

Avatar

Level 10

Thanks for this, cverges-medallia.
The part I'm uncertain on how to create is the last part, the removal of association to hours and setting the hours to an empty array/null.   Are you able to show a screenshot of how you would set up that module?

Avatar

Correct answer by
Level 6

I think you have to use the Custom API Call module (at least, that's how we do it).  Here's an example pipeline that gets to just the deletion portion.  Note that it's simply about setting the hours value to an empty array.

Screen Shot 2023-09-20 at 12.02.43 PM.png

Avatar

Level 10

Perfect, that worked!  Thanks, cverges-medallia.

My goal with this is to remove certain hour records from billing records so I can then make some user cost rate updates, and the costs for those hours I pulled out of the billing records calculates at the correct rate.

Once I make the user cost rate updates, I want to re-add the hour records I removed from the billing record and put them back in the billing records.  Do you know if the API method is best for that, and if so, are you able to provide some guidance again?

Avatar

Level 6

Sure, it's the same, just in reverse and using a POST/PUT (depending on whether you're creating or updating):

 

{
  "hours": [
    "123",
    "456",
    "789",
    ...
  ]
}

 

where each of the entries in the array are the IDs of the hour object that you want associated to the billing record.

Avatar

Level 10

Great, thanks.
Do I need to list the hour record ID's, like you did in the above example, if I have many billing records with many hour records, or is there some sort of relative reference that can be used in the API Body so I don't have to one billing record at a time and list all of the associated hour id's?

 

Screenshot 2023-09-21 at 12.40.43 PM.png

 

 

Avatar

Level 6

There is perhaps a way to do it, but I would point you to Adobe PS and/or support for guidance on this.  It uses an unpublished feature of the API and we had to receive special dispensation to use it.  (Not saying we're special, just don't want to publicly go against Adobe's standard position on this.)