How to install Tridion ApplicationData using Anguilla JavaScript?

I have a GUI extension for tabs with a form and text box. I would like to store the values โ€‹โ€‹of the form field in ApplicatioData. I was thinking about the refresh button, calling the Anguilla method.

Is there a way to Anguilla? I do not see any methods for this in Anguilla. Start of code:

var c = $display.getItem(); var uri = c.getId(); 
+5
source share
1 answer

Anguilla does not provide any methods (webservice or JavaScript) for a general change to ApplicationData. You will need to specify your own server code in order to install ApplicationData.

So, in my last need for this, I wrote a simple WCF web service that installs application data:

 [ServiceBehavior(InstanceContextMode = InstanceContextMode.Single, ConcurrencyMode = ConcurrencyMode.Multiple)] [AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Required)] [ServiceContract(Namespace= "ExtensionsModel.Services")] public class ExtensionsService { [OperationContract] [WebInvoke(Method = "POST", RequestFormat = WebMessageFormat.Json, ResponseFormat = WebMessageFormat.Json)] public void SetEnabled(string[] itemIDs, bool enabled) { using (var client = TridionCoreService.GetSessionAwareClient()) { var appdata = new ApplicationData(); appdata.ApplicationId = "ext:IsEnabled"; appdata.Data = new ASCIIEncoding().GetBytes(enabled ? bool.TrueString : bool.FalseString); foreach (var itemID in itemIDs) { client.SaveApplicationData(itemID, new[] {appdata}); } } } } 

Connected it in the configuration file of my model:

 <?xml version="1.0" encoding="utf-8" ?> <Configuration> <!-- namespaces removed for readability --> <resources cache="true"> <cfg:filters/> <cfg:groups> <cfg:group name="Extensions.Models"> <cfg:domainmodel name="Extensions.Models"> <cfg:services> <cfg:service type="wcf">Services/ExtensionsService.svc</cfg:service> </cfg:services> </cfg:domainmodel> </cfg:group> </cfg:groups> ... 

Then call this web method from my command._execute

 Extensions.Commands.DisableExtension.prototype._execute = function (selection) { ExtensionsModel.Services.ExtensionsService.SetEnabled(selection.getItems(), false); }; 
+6
source

All Articles