Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
BedrockMission!

Learn more

View all

Sign in to view all badges

SOLVED

Fetch node property value of asset whose Properties page is open

Shaheena_Sheikh
Level 4
Level 4

I have added a new dropdown to the asset Properties page. I have also added a custom validation file to the asset metadata schema. When I select any asset and open the Properties page, the JS file loads. 

I wanted to verify the value of some node properties-value (like title, mime type etc) of the asset whose Properties page is open. But i dnt know how can i get the resource and its property values.

1 Accepted Solution
Anudeep_Garnepudi
Correct answer by
Community Advisor
Community Advisor

@Shaheena_Sheikh 

You can do an AJAX call from your custom JavaScript to get the asset Node values. Try the below code.

 

let props  = $.getJSON($("form[data-formid]").data("formid")+".infinity.json");

// To get metadanode values
let props  = $.getJSON($("form[data-formid]").data("formid")+"/_jcr_content/metadata.json");

// Get specific property value
let mimeType = props.responseJSON["dam:MIMEtype"];

 

 Hope this works.

View solution in original post

4 Replies
Anudeep_Garnepudi
Correct answer by
Community Advisor
Community Advisor

@Shaheena_Sheikh 

You can do an AJAX call from your custom JavaScript to get the asset Node values. Try the below code.

 

let props  = $.getJSON($("form[data-formid]").data("formid")+".infinity.json");

// To get metadanode values
let props  = $.getJSON($("form[data-formid]").data("formid")+"/_jcr_content/metadata.json");

// Get specific property value
let mimeType = props.responseJSON["dam:MIMEtype"];

 

 Hope this works.

View solution in original post

Shaheena_Sheikh
Level 4
Level 4
Can you please provide some link which I can use to explore further more on this one?
Shaheena_Sheikh
Level 4
Level 4
Your code sure works but it fetches alot of data in the response. How can i use a loop or something to get details of its children?
Anudeep_Garnepudi
Community Advisor
Community Advisor
Hi @Shaheena_Sheikh, If you want to get the meatadata node values just use /_jcr_content/metada in place of .infinity. I have updates my answer above check.