Is it possible to save a file using client side javascript in xpages - xpages

I customize my confirmation prompt using sweetAlert, I did it, now my problem is using a customize confirmation prompt, I cannot use SSJS code but I need to save a document with a file upload.
I need Help with this thanks!

My workaround for this is an XPoages button that contains the required SSJS code for saving the document. The button resides in a hidden normal DIV (style="display:none"). When executing you CSJS just refer to the clientId of that button and fire the event click() like in
function csjsAction(){
dojo.byId("#{id:yourButton}").click();
}

Related

How to show a button on Customer Form only in view mode?

I created a button to redirect to an external page on the customer form on NetSuite through SuiteScript and it shows only in EDIT mode, but I want to show it only in VIEW mode. What can I do to fix it?
I tried some script lines but didn't work. The button is working properly redirecting to the external page, the problem is only about showing in the correct place, which is ONLY on VIEW mode.
You need to add context type in the user event script beforeLoad(context),
just add this line in the before load function at top.
Note- in Function if you using beforeLoad(context) then use context else use sriptContext.
if (sriptContext.type !== sriptContext.UserEventType.VIEW)
return;
It will work.
Thanks.

Custom Form issue - NGM Forum thread section in Orchard CMS

I am using the external module, NGM Forum.
In thread create form the Save button is not inside the <form> tag.
So when I press save it's not submitting the form.
How can I get the Save button back inside the form?
Please refer to the attached images:
Placement.info
It could be that you have customised the form somehow with your placement.info file and moved the save button down.
Edit form on create form?
Looking at the code from your screenshot it looks like you are on the /Create/ action, and your form tag confirms this with the id="thread-create". Code.
But the Save button is for the Edit action with submit.Save.
You must have made some mistakes with your changes before this point so you will need to explain how you built this form further I think for anyone to help you resolve it.

Can't open Xpages Dialog from a client-side included script

It seems the only way to open a client-side dialog is from within an embedded control which doesn't work for me. Most of my coding to populate the dialogs is contained in an external script library, yet when I try to XSP.openDialog(id) I receive a jumbled javascript error on Firebug.
I have tried
Accessing the object (an extension library dialog) directly from a button on the xpages. It opens without a problem
Calling a script function from an embedded button and passing the id of the dialog. Error.
Created a global variable containing the id of the dialog and called directly from a button. WORKS
Same global variable, but called in a javascript function. ERROR
from within script created variable with dojo.byId. ERROR
Is there something else I need to configure? Many of the buttons I will be using are also dynamically generated from a JSON-supplied feed.

How do I create a messagebox to inform successful save in xpages?

I've set my button to 'Submit'. The XPage is set to stay on the same page if save is successful. How do I create a messagebox to inform user the save is successful?
There are a number of options you can consider. A msgbox is the least desirable.
You could add an information message on top of the form that either fades after a few seconds or on change. The custom control would show when you set a viewScope variable (e.g. viewScope.saveSuccess ) and have a visibility formula for it. It also would register an event listener to hide when a field is altered. You also could consider redirecting to a different page.
This post already asks a similar question to do with how to call a client side script from server side, could be useful.
client message after SSJS routine how?
Here are two examples that I have used as inspiration to create a custom control for error messages and for info messages such as what you are asking for:
http://openntf.org/XSnippets.nsf/snippet.xsp?id=ssjs-form-validation-that-triggers-errormessage-controls
http://lotusnotus.com/lotusnotus_en.nsf/dx/xpages-tip-a-simple-cc-for-prompting-ssjs-messages-to-ui....htm
The easiest way to call csjs after running ssjs is to add code the event handler's onComplete event. The onStart, onComplete, and onError events run client side js before or after your ssjs, but are only executed during a partial page refresh.
The simplest way is to add this line of code (or the CSJS you prefer) in the postSaveDocument event:
view.postScript('alert("Document saved")');

client message after SSJS routine how?

I have a Button that in SSJS send and Email...
Now I would if is possibile show the status of sending of email in real-time to the user:
sending process....
sending Successful or sending error
How Can i call a JS client codice from SSJS routine?
Have you any suggest?
If you are using ExtLib then you can also use the #WarningMessage('messageText') method.
You will need to add a section to the XPage to display the messages. It can be as simple as
<xp:messages id="messages1"></xp:messages>
Once added each call to #WarningMessage will add a line to the messages pane.
8.5.3 introduced a very nice approach:
view.postScript
you may insert any CSJS code you like from the SSJS code.
This is quite straightforward.
1. Add a Hidden Input control on your page, noting the id.
2. In your SSJS use getComponent("inputHidden1").setValue("This is the message")
3. Ensure the Hidden Input control is in the area being refreshed (otherwise the value doesn't get passed back to the browser, so can't be accessed in CSJS)
4. Go to the Source pane and place the cursor on or in the eventHandler that is triggering your SSJS. You need to do this to get to the onComplete event
5. In All Properties panel go to onComplete, add your CSJS there. e.g. alert(dojo.byId("#{id:inputHidden1}").value)
This will run your SSJS and on completion alert the user with whatever code is in the field.
For a demo and demo code, check out my blog post: http://www.intec.co.uk/xpages-calling-client-side-javascript-from-server-side-javascript/
Another way to do it besides Pauls answer is to use a dialog from the extlib, and you can call it from ssjs, put a field in a dialog and set it to a scope value and show the dialog.

Resources