I have a Tab GUI Extension with a form and a text field. I would like to save the values of the form field to ApplicatioData. I was thinking of an 'Update' button calling an Anguilla method.
Is there an Anguilla method to do this? I don't see any method in Anguilla for this. Start of the code:
var c = $display.getItem();
var uri = c.getId();
Anguilla doesn't expose any (webservice or JavaScript) methods to generically modify ApplicationData. You will have to provide your own server-side code to set the ApplicationData.
So in my last need for this I wrote a simply WCF web service that sets the 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});
}
}
}
}
Wired it up 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>
...
And then call this web method from my command._execute
Extensions.Commands.DisableExtension.prototype._execute = function (selection) {
ExtensionsModel.Services.ExtensionsService.SetEnabled(selection.getItems(), false);
};
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With