How can i trigger event in onlyoffice - onlyoffice

I am using Onlyoffice 5.0.3. I have altered Onlyoffice code for adding new menu under file menu shown in below image
and i have added action script also.
case "approval":{
Common.UI.custom({
closable: false,
title: "Confirm",
msg: "Are you sure, do you want to confirm the Approve",
buttons: ["approve","reject"],
primary: approve,
iconCls:"warn",
callback: _.bind(function (e) {
if(e=="approve"){
// here i want to trigger event which is given in docEditor Api.
}
else{
}
}, this);
})
break;
}
my problem has to trigger an event which is given in docEditor API.

by using Common.Gateway.eventName(); I have triggered event, which is given in docEditorAPI.

There is no way to do it in the current version.
Please contact ONLYOFFICE team directly to discuss all possible ways how this option can be realized.

Related

Editing Non-G/L custom Transaction Fields in Assembly Build "View"

I'm looking to try and see if there is a way to enable a Non-G/L "check box" custom field to be able to be checked or unchecked from the 'View' status of a G/L Posting Transaction (Item Receipt or Assembly Build, etc.). The purpose of the field is to be able to be used for audit error tracking and would like to see if it can be edited in such a way, and then by such logic, allow for those fields to be edited on Closed periods where "Allow Non-G/L Changes" has been checked on.
Can't seem to find any such options on the "Custom Record" field or the "Custom Transaction Form", so wondering if anyone knows if there's a specific permission or option that needs to be set aside from the "Allow Non-G/L Changes". Thanks!
Example Transaction Check Box Fields
TLDR: Allow Non-G/L Changes is enabled in the closed period of my transaction; however, since I am unable to "edit" this transaction, I cannot check the non-G/L impacting custom field Checkbox that is on those transactions, and need to figure out if there is a way to edit fields without being in "edit mode".
If I understand your problem correctly, you want to (from view context) be able to update the values of those 3 checkboxes. Correct?
There might be a better way to do this, but you can add buttons to the record using a UserEvent script that call a ClientScript similar to this.
/**
* #NApiVersion 2.x
* #NScriptType UserEventScript
*/
define([], function () {
function beforeLoad(context) {
// make sure not to add the button in create or edit context
if (context.type !== context.UserEventType.VIEW) return;
context.form.clientScriptModulePath = "SuiteScripts/Path/To/Your/Script.js";
context.form.addButton({
id: "custpage_button",
label: "My Label",
functionName: "checkBox.call(this)",
});
}
return {beforeLoad: beforeLoad};
});
/**
* #NApiVersion 2.x
* #NScriptType ClientScript
*/
define(["N/currentRecord", "N/record"], function (currentRecord, record) {
// this function should be named whatever you are defining in your user event script as the "functionName" when adding the button
function checkBox() {
var curr = currentRecord.get();
// check the checkbox
record.submitFields({
id: curr.id,
type: curr.type,
columns: {
custbody_mycheckbox: "T",
},
});
// reload the page to present the most up to date information
window.location.reload();
}
return {
pageInit: function () {},
checkBox: checkBox,
}
});

Cant trigger message after reloadaction

After I enter "reset", I does not received any message "Welcome Back" and restart the conversation.
bot.dialog('reset', [
function(session) {
session.send("Welcome Back");
session.beginDialog('/');
}]
)
.reloadAction('reset', 'Ok, starting over.', {
matches: /^reset/i,
});
The reloadAction only works for dialogs that have already been added to the stack. In order to use it correctly, the reloadAction needs to be attached to a dialog that has already been called/used previously.
For example, if a user is responding to a series of user profile questions across multiple dialogs (personal info, then address/previous address, followed by education) and the user types 'reset' while in the education dialog, then the reloadAction would trigger having been attached to the first user profile dialog (that collects personal info). Thus, the user would be brought back to the beginning of the user profile dialogs to start over.
If you are intent on calling a new dialog, then you will likely want to use triggerAction. This does clear the dialog stack entirely but also allows you to redirect back to dialog x. In this way, you achieve the same result as in your ask with just a little bit of extra code:
bot.dialog('reset', [
function(session, args, next) {
session.send("Ok, starting over.");
next();
},
function(session) {
session.send("Welcome Back");
session.beginDialog('/');
}]
).triggerAction({
matches: /^reset/i
});
Hope of help!

jquery jtable deleteConfirmation function not working

I am trying to use the deleteConfimation function option but I find that the default confirmation box pops up before I even get into the deleteConfimation function - what am I missing?
In the code below I can set break points and watch the data object being set up correctly with its new defaultConfirmMessage, but the basic jtable default delete confirmation box has already appeared and I never see an altered one.
$(container).jtable({
title: tablename,
paging: true,
pageSize: 100,
sorting: true,
defaultSorting: sortvar + ' ASC',
selecting: false,
deleteConfirmation: function(data) {
var defaultMessage = 'This record will be deleted - along with all its assignments!<br>Are you sure?';
if(data.record.Item) { // deleting an item
// Check whether item is in any preset lists
var url = 'CampingTablesData.php?action=CheckPresets&Table=items';
$.when(
ReturnAjax(url, {'ID':data.record.ID}, MyError)
).done(
function(retdata, status) {
if(status=='success') {
if(retdata.PresetList) {
data.deleteConfirmMessage = 'Item is in the following lists: ' + retdata.PresetList + 'Do you still want to delete it?';
}
} else {
data.cancel = true;
data.cancelMessage = retdata.Message;
}
}
);
} else {
data.deleteConfirmMessage = defaultMessage;
}
},
messages: {
addNewRecord: 'Add new',
deleteText: deleteTxt
},
actions: {
listAction: function(postData, jtParams) {
<list action code>
},
createAction: function(postData) {
<create action code>
},
updateAction: 'CampingTablesData.php?action=update&Table=' + tablename,
deleteAction: 'CampingTablesData.php?action=delete&Table=' + tablename
},
fields: tableFields --- preset variable
});
==========
After further testing the problem is only when deleting an item and it goes through the $.when().done() section of code. The Ajax call to the deletion url does not wait for this to complete - how do I overcome this?
i don't think you can get your design to work. What does the A in ajax stand for? Asynchronous! Synchronous Ajax has been deprecated for all sorts of good design and performance reasons.
You need to design you application to function asynchronously. Looking at your code, it feels you are misusing the deleteConfirmation event.
Consider changing the default deleteConfirmation message to inform the user, that the delete might not succeed if certain condition are met. Say
messages: {
deleteConfirmation: "This record will be deleted - along with all its assignments, unless in a preset list. Do you wish to try to delete this record?"
},
Then on the server, check the preset lists, and if not deletable, return an error message for jTable to display.
Depending on how dynamic your preset lists are, another approach might be to let the list function return an additional flag or code indicating which, if any, preset lists the item is already in, then your confirmation function can check this flag / indicator without further access to the server.
Thanks to MisterP for his observation and suggestions. I also considered his last approach but ended up setting deleteConfirmation to false (so as not to generate a system prompt) then writing a delete function that did not actually delete, but returned the information I needed to construct my own deleteConfimation message. Then a simple if confirm(myMessage) go ahead and delete with another Ajax call.

Microsoft Bot framework session.endDialog() use

I read the Bot document somewhere people posted if you replace dialog then previous dialog store in stack and stored somewhere.
Now I tried to follow the way to endDialog() then replaceDialog();
callRequest.GetWebAPICall(session, urlData, function (body) {
if(body.statusCode == 200) {
if(body.data == undefined) {
builder.Prompts.choice(session,Want to Select List?", "Yes|No",{listStyle: builder.ListStyle.button});
} else {
session.endDialog();
session.replaceDialog('/Show List');
}
} else {
session.send('Something went wrong. You can use the back or top command.');
session.replaceDialog('/menu');
}
});
For need to know if I replace below lines
session.endDialog();
session.replaceDialog('/Show List');
by
session.endDialog('/Show List');
No. endDialog() doesn't have the functionality to start a new dialog. You can refer to the function definition interface endDialog(message?: TextOrMessageType, ...args: any\[\]): Session;.
In your case, '/Show List' would be sent to the user as a message.
And there is also a misunderstanding about replaceDialog().
Ends the current dialog and starts a new one its place. The parent dialog will not be resumed until the new dialog completes.
If you need to store the previous dialog, you can use beginDialog()

Multiple buttons in HeroCard

I'd like to have multiple buttons on HeroCard
and be able to press all buttons one after another
but when I press click button program jumps to next function in waterfall
and expects next action instead of button action again
what should I do in this case?
bot.dialog("/showCards", [
(session) => {
const msg = new Message(session)
.textFormat(TextFormat.xml)
.attachmentLayout(AttachmentLayout.carousel)
.attachments([{
title: "title",
url: "https://www.wikipedia.org/portal/wikipedia.org/assets/img/Wikipedia-logo-v2.png"
}].map(obj =>
new HeroCard(session)
.title(obj.title)
.images([
CardImage.create(session, obj.url)
.tap(CardAction.showImage(session, obj.url)),
])
.buttons([
CardAction.openUrl(session, obj.url),
CardAction.imBack(session, `click`, "Click"),
CardAction.imBack(session, `clack`, "Clack")
])
));
Prompts.choice(session, msg, ["click", "clack"]);
},
(session, results) => {
// todo use results.response.entity
}
]);
You could also use CardAction.dialogAction and link every button to a beginDialogAction.
let card = new builder.HeroCard(session)
.title(title)
.subtitle(subtitle)
.buttons([builder.CardAction.dialogAction(session, 'dialogAAction', 'dataYouNeedInDialogA', 'ButtonTitleA'), builder.CardAction.dialogAction(session, 'dialogBAction', 'dataYouNeedInDialogA', 'ButtonTitleB')]);
let msg = new builder.Message(session)
.attachments([card])
session.endDialog(msg);
// use one of these two to either end the dialog and start a new one or to stay in the current dialog and wait for user input
session.send(msg);
// don't forget to add the dialogs to your bot / library later in your code (outside your current dialog)
bot.dialog('dialogA', dialogA); // initialized somewhere in your code
bot.dialog('dialogB', dialogB);
bot.beginDialogAction('dialogAAction', 'dialogA');
bot.beginDialogAction('dialogBAction', 'dialogB', {
onSelectAction: (session, args, next) => {
// you might want to clear the dialogStack if the button is pressed. Otherwise, if the button is pressed multiple times, instances of dialogB are pilled up on the dialog stack.
session.clearDialogStack();
next();
}
});
In my opinion, this is the best way to achieve the behaviour you described so far. All buttons work whenever the user presses them, even if they scroll back in the conversation and press the same button again. The only trade-off is that you have to pass data to the new dialog and can not use dialogData throughout the whole flow. Nevertheless, I think it's worth it because ensures consistent UX throughout the usage of the bot.
Hope this helps. You can build click and clack dialogs, link them to actions and pass the data that you need. The user would be able to press click, clack, click and the bot would still work. :)
Use a switch-case in the ResumeAfter function, in the default case send the user to the previous function.

Resources