Take the 2-minute tour ×
Tridion Stack Exchange is a question and answer site for Tridion developers and administrators. It's 100% free, no registration required.

We have the below code

var itemType = $models.getItemType(selection.getItem(0));
if itemType == $const.ItemType.COMPONENT  

I want to check which schema is used for this component, based on this I want to enable user defined button in the ICM ribbon.

Please share the code how to check the component based on particular schema in JavaScript.

share|improve this question
    
You question title and description is confusing, in title it says. "component based on schema", & in description it says. "which schema is used for this component", Please clean your question –  Raj Kumar Jun 25 at 9:35
add comment

2 Answers 2

You may want to refer the below code to retrieve items filtered on the basis of a Schema TCM URI in Anguilla Framework:

$item = $models.getItem(id); 
$criteria = new Tridion.ContentManager.ListFilter();
$criteria.conditions.ItemTypes = 16;                //Get all items of type Component
$criteria.conditions.BasedOnSchema = "tcm:1-100-8"; // TCM URI of your Schema
$criteria.conditions.InclLocalCopies = true;       // Retrieve the Local Copies as well

// List of Components based on schema in Criteria
$list = $item.getListUsingItems($criteria, false, false); 

I hope this helps you start.

share|improve this answer
    
i think he is asking to find the schema, but your answer suggest user should already know the schema id. i also think question is also confusing –  Raj Kumar Jun 25 at 9:33
add comment

You can use following script to get schema Title: taken from http://stackoverflow.com/questions/11257535/how-to-get-the-schema-name-from-the-schema-object-in-tridion

var schemaObject = $models.getItem("tcm:8-32597").getSchema();
var schemaTitle;
function loaded()
{
    schemaTitle = schemaObject.getTitle();
}
$evt.addEventHandler(schemaObject, "load", loaded);
schemaObject.load(true);
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.