Solved

Add Cityworks Inspection attachments using FME Form

  • 22 May 2024
  • 3 replies
  • 76 views

Badge +2

Hi, I am trying to add Inspection attachments to the Inspections using FME Form.

I have excel spreadsheet that have EntityUID, InspectionTemplateId, Observations Questions and Answers, and image links1 - to image link4(attachments)

Each Inspection must have entity attach to it based on the EntityUID. Image as JPG extension located on the repository an each image have EntityUID in the image name.

How can I attach image to the Inspection- that is first question

Second question is that some Entities have up to 4 images related to them, that reference based on the different parameter (Image_link1, image_link2,image_link3, and image_link4)  

It is easy to create inspection, add entity, and populate Observations questions and answers but I am struggling to attach the images.

 

icon

Best answer by sanaeatsafe 24 May 2024, 22:41

View original

3 replies

Userlevel 1
Badge +6

Hi @serg42932 , 

From the HTTPCaller, you can make a POST request to the /Attachments/AddInspectionAttachment endpoint to upload images to each Inspection. 

Here is an example: 

 

The image file names can be configured upstream, then the images can be uploaded form the Body (as pictured).

Renaming files in FME is a little tricky. The File Copy writer is one way, with an example here: https://community.safe.com/data-7/is-there-a-quick-way-to-rename-files-10626#:~:text=You%20can%20use%20the%20%22Directory,files%20to%20a%20new%20location

Let us know how that goes! 

Thanks, 

Sanae

Badge +2

Hi @sanaeatsafe,

Thank you for your response. 

Ok, it is kind of working but not exactly doing what I want it to do.

I have excel spreadsheet with parameters as headers , that identifies by the FME Form as parameters: Image_Link1, Image_Link2, Image_Link3, and Image_Link4. Each Inspection that will be created in Cityworks can have minimum one image and maximum four.

How I can configure HTTP Caller, so it will addattachments to the Inspection by referencing spreadsheet and attaching image if there is value for the parameters Image_Link1, Image_Link2, Image_Link3, and Image_Link4?

I tried to set is this way:

 

This is the error it gives me- I have sample spreadsheet with 3 InspectionID’s and workspace stop running after first HTTP Caller trying to AddAttachment.

 

Thank you,

 

Sergiy

Badge +2

Hi @sanaeatsafe ,

Just want to thank you for your help.

I manage to create a multi step automation that create Inspection, attach Entity, update Inspection, and attach related images :)

There was two things that I wasnt able to complete easy- transform date (dd-mm-yyyy) to the format that I can populate Cityworks Inspection Date field.

I end up using Attribute Manager where for value I use this:@DateTimeFormat(@Value(Insp. Date),ISO)- that change Date Format to: YYYY-MM-DD.

 And then- using string concatenator and add T18:00:00Z to the date, so then API Call was populating Inspection Date field.

Second issue is: one field had values: 8”, 12”, and 16”- where “ was for inches and in the Cityworks Inspection Observation Answers was configured as This Text.

When I pull Inspection QA API Call to get all the QuestionId, AnswerId’s- values for the 8”,12”, and 16” was recorder as such: “8\””, “12\””, and “16\””.

So, if I were to use 8”,12”, 16” as dynamic values- HTTP Caller was giving me an error.

And when I was trying to configure 8,12, and 16 numbers by adding /” or /u0022- HTTP Caller was running but it was not updating the Inspection Observation Answer.

The syntax in the data parameters was: {“InspectionId”:”xxxxx”,“Answers”:[{“QuestionID”:”xxxxx”,”AnswerId”:”xxxxx”,”AnswerValue”:”AnswerValue”}]}

If you have better idea of how to accomplish this two issues- can you please advise.

 

Thank you,

 

Sergiy.

Reply