Quantcast
Channel: Mockaroo Community Forum - Latest posts
Viewing all articles
Browse latest Browse all 2665

How to set a column based on the value chosen from a dataset on another column

$
0
0

Assuming I have a column named project_media_type which is populated with a random value from this dataset:

  • image
  • animated_gif_player
  • embedded_video
  • embedded_iframe
  • embedded_code_snippet
  • image_gallery
  • etc...

Next I also have these 2 columns code and code_embedded

I want to do this if possibble:

  • Make both code and code_embedded columns be null if project_media_type does not have a value of embedded_code_snippet

next I also want to make column code null if project_media_type does have a value of embedded_code_snippet however embedded_code_snippet is a JSON field which has another hidden column embedded_code_snippet.code_source

Now embedded_code_snippet.code_source picks a value from another dataset which has options

  • codepen
  • jsfiddle
  • jsbin
  • gist
  • local

so when embedded_code_snippet.code_source picks a value of local I would then like to populate the column code with random code/text data

I know this sounds confusing but it is simple when you think about it. I am just not sure if it is too complex for Mockaroo?


More simple view if a do a if/else block...

if(  project_media_type === 'embedded_code_snippet' ){

    // column embedded_code_snippet is a JSON data type
    // embedded_code_snippet.code_source is populated from a dataset

    if( embedded_code_snippet.code_source === 'local' ){
        // make column code = random code/text
    }else{
        // make column code = null
    }
}else{
    // make column code = null
    // make column embedded_code_snippet = null
}

Viewing all articles
Browse latest Browse all 2665

Trending Articles