Can I load a controller script from the customspace?
I have a script that will put the affected user and WI info inside a template when using SendEmail (portal task). The issue, I have to edit the controller.js inside the SendEmail task folder which lies outside the customspace folder. Is there a way that I can load this edited js using the custom.js (only when the email task is loaded)?
Answers
You mean so you can invoke the Send Email window and your custom code at the same time? IF so, you could invoke its click function.
$('.cs-form__task--sendEmail').click()
I mean so the script only loads when the SendEmail form is loaded Much like you do when it's a request offering (loadScript('/CustomSpace/Request-on-Behalf.js',["RequestOffering"]))
This might be kind of rough, but my approach would be to hide the original task and add an alternate task. Something like this:
In custom.css: .cs-form__task--sendEmail {display: none;}
In custom.js:
app.custom.formTasks.add('Incident', 'SendMail', function (formObj, viewModel) {
$('.cs-form__task--sendEmail').click();
//your custom code here
});
.cs-form__task--sendEmail {display: none;} does not hide the task The bit I am looking to insert is this:
As Previously stated, the code/script/concept works beautifully. However, I need to call it from the CustomSpace to allow for portal upgrade and so on with nothing breaking.