Best answer

Providing default values for missing fields

  • 3 November 2021
  • 3 replies
  • 129 views

I’m creating a series of integrations based on Youtube/new video in channel event. Sometimes we are observing missing fields such as thumbnail URLs.

Before applying more complex business logic, such as using Paths to tag videos differently in Ghost based on title, we’d like to ensure that missing fields are populated with default values (such as default image url for missing thumbnails). 

 

How do we achieve that?

icon

Best answer by resetobywatelski 3 November 2021, 13:48

View original

This post has been closed for comments. Please create a new post if you need help or have a question about this topic.

3 replies

Userlevel 7
Badge +14

Hi @resetobywatelski 

TIP: You can use the .join() method in the JavaScript Code block to combine an array: https://www.w3schools.com/jsref/jsref_join.asp

I’m experimenting with the Code task, which seems to have answered the question. However the problem I’m facing now is that I’m getting an internal server error when attempting to push the post to Ghost

 

Below is the output of my Code (js) task

output = [{
  id: id,            // string
  title: title,      // string
  description:  
  description,  // string
  thumbnail:    
  thumbnail,
  tags: tags.   // array of strings
}];


Will the Ghost task accept the string[] as a Custom input to it’s tags field? Or does it expect a different input?

Userlevel 7
Badge +11

Hey @resetobywatelski,

I’m so glad you were able to come up with a solution here, great work! :)

With the second issue, looking at the Create Post action for Ghost it seems that the Tags field requires a list of tags rather than an array:

d02b7fee60eda64b5c2c1bb393487b0a.png
So I’d imagine that a comma separated list of the different tags would work here. Though you’d likely need to ensure that you’re using the ID for the tag rather than it’s name. The ID is usually the value that appears in grey in the dropdown menu, for example: 

8fc20c60513143d6a12c7d258a3b2bb5.png

Hopefully that’ll do the trick!