I have a document library which has two custom types linked to it. From UI I have two buttons to add that items..
I have two simple "ribbon button" and I want to use that to create the new Item from Content Type 1 and Content Type 2...
What's the Command I must associate? Is it possile to create this by Javascript?
Another question... If I want to make some button visible ONLY in certain conditions (like I'm in folder XXX so I can create only Content Type XXX elements), how can I do?
EDIT: According with Ren Hoek's answer, I create this code:
<CustomAction
Id="AggiungiCliente"
RegistrationType="List"
RegistrationId="101"
Location="CommandUI.Ribbon">
<CommandUIExtension>
<CommandUIDefinitions>
<CommandUIDefinition
Location="Ribbon.Documents.New.Controls._children">
<Button
Id="Ribbon.Documents.New.Controls.AggiungiCliente"
Alt="Aggiungi Cliente Ribbon Button"
Sequence="10"
Image32by32="/_layouts/images/PeoplePermissions.png"
Command="AggiungiClienteCMD"
LabelText="Aggiungi Cliente"
TemplateAlias="o2"/>
</CommandUIDefinition>
</CommandUIDefinitions>
<CommandUIHandlers>
<CommandUIHandler
EnabledScript="true"
Command="AggiungiClienteCMD"
CommandAction="javascript:var PAGETYPE = { ItemDisplay: 4, ItemEdit: 6, ItemNew: 8 };
var baseListFormUrl = '/_layouts/listform.aspx?';
var FolderConTypeID = '0x01200016274670493a402ab037bb0597921f54';
function NewFolder() {
alert('done');
openPopup( baseListFormUrl +
'ListId=' + escapeProperly(listid) +
'%26PageType=' + PAGETYPE.ItemNew +
'%26RoorFolder=' + escapeProperly(L_Menu_BaseUrl + '/' + folderpath) +
'%26ContentTypeId=' + FolderConTypeID
);
}
function openPopup(popUpUrl) {
alert('called');
var options = {
url: popUpUrl,
title: 'title',
allowMaximize: false,
showClose: true,
width: 600,
height: 500,
dialogReturnValueCallback: refreshCallback
}
alert('invoking showModalDialog')
SP.UI.ModalDialog.showModalDialog(options);
alert('invoked');
} " />
</CommandUIHandlers>
</CommandUIExtension>
The button appears, but no one of the "alert" is hitted. If I change my code and put only "javascript:alert("...")" it works...
Any suggestion?
Thank you very much!