Display of the standard task of Cireson in the closed WI
Hi guys!
I need to display in the closed WI the standard task of Cireson - "Print".
Help, please!
Best Answer
-
Roland_Kind Partner Advanced IT Monkey ✭✭✭
Hi,
the timinig can be a little bit difficult, but the following approach might help to use Cireson predefined tasks on closed WI:
$(document).ready(function ()
{
var pathArray = window.location.href;
var allowedLinks = ['ServiceRequest','Incident', 'Change', 'View'],
length = allowedLinks.length;
while(length--) {
if (pathArray.indexOf(allowedLinks[length])!=-1)
{ // taken from wimain.js
require.config({
waitSeconds: 0,
urlArgs: "v=" + session.staticFileVersion,
baseUrl: "/Scripts/",
paths: {text: "require/text"},
shim: {}
});
if (typeof pageForm !='undefined')
{
if (pageForm.viewModel.Status.Id == "f228d50b-2b5a-010f-b1a4-5c7d95703a9b") // Status "closed Change"
{
setTimeout(function () { //taskspane not loaded - wait some time ...
var ulElement=$('.task-panel');
ulElement.append("<h2>Tasks</h2><ul class='taskmenu'></ul>");require(["forms/tasks/print/controller"], function (prController) {
task={"Label": "My Print", "Task": "prController", "Configs" : {}};
eval("var _obj = " + task.Task + ";");
_obj.build(pageForm, task, function (view) {
ulElement=$('.taskmenu');
ulElement.append(view);
});
});require(["forms/tasks/sendEmail/controller"], function (emailController) {
task={"Label": "My eMail", "Task": "emailController", "Configs" : {}};
eval("var _obj = " + task.Task + ";");
_obj.build(pageForm, task, function (view) {
ulElement=$('.taskmenu');
ulElement.append(view);
});
});
}, 2000);
};
};
}
}3
Answers
However, I have since updated the code a bit:
"func2()", "func3()", and "func4()" are just placeholders, of course, but I added the function for printing at the top for you.
Note that for me, this is running inside of a script that is only loaded if the current page is a CR form, so if you are just dropping this into your custom.js file, you may want to wrap it in another IF statement that checks to see that the current page is one of the work item forms.
Thanks, but this code doesn't allow to use the built-in tasks Cireson such as:
- Print: inetpub\CiresonPortal\Scripts\forms\tasks\print\
- sendEmail: inetpub\CiresonPortal\Scripts\forms\tasks\sendEmail\
- etc.
I already saw your decision, but it didn't suit me.
This code will get the task panel to appear so that you can attach tasks, but someone from Cireson will have to step in to explain how to add their OOB tasks. I have not been successful in my attempts.
If someone from Cireson would be so kind as to either convert my original request (which is in the feature request folder but the voting buttons never appeared) or this one into a feature request, perhaps we can get enough votes for Cireson to make this work OOB (which I prefer to using this code).
Converted your original post and upvoted.
I voted in a request: https://community.cireson.com/discussion/comment/3048#Comment_3048
I need extremely it!
Hi,
the timinig can be a little bit difficult, but the following approach might help to use Cireson predefined tasks on closed WI:
$(document).ready(function ()
{
var pathArray = window.location.href;
var allowedLinks = ['ServiceRequest','Incident', 'Change', 'View'],
length = allowedLinks.length;
while(length--) {
if (pathArray.indexOf(allowedLinks[length])!=-1)
{ // taken from wimain.js
require.config({
waitSeconds: 0,
urlArgs: "v=" + session.staticFileVersion,
baseUrl: "/Scripts/",
paths: {text: "require/text"},
shim: {}
});
if (typeof pageForm !='undefined')
{
if (pageForm.viewModel.Status.Id == "f228d50b-2b5a-010f-b1a4-5c7d95703a9b") // Status "closed Change"
{
setTimeout(function () { //taskspane not loaded - wait some time ...
var ulElement=$('.task-panel');
ulElement.append("<h2>Tasks</h2><ul class='taskmenu'></ul>");
require(["forms/tasks/print/controller"], function (prController) {
task={"Label": "My Print", "Task": "prController", "Configs" : {}};
eval("var _obj = " + task.Task + ";");
_obj.build(pageForm, task, function (view) {
ulElement=$('.taskmenu');
ulElement.append(view);
});
});
require(["forms/tasks/sendEmail/controller"], function (emailController) {
task={"Label": "My eMail", "Task": "emailController", "Configs" : {}};
eval("var _obj = " + task.Task + ";");
_obj.build(pageForm, task, function (view) {
ulElement=$('.taskmenu');
ulElement.append(view);
});
});
}, 2000);
};
};
}
}