I try to create a button which send a mail using the doc's URL to a mail-adress entered in an editBox:
if(Contr.isNewNote()){
Contr.save();
}
var thisdoc = Contr.getDocument(true);
var tempdoc = database.createDocument();
tempdoc.replaceItemValue("Form", "Memo");
tempdoc.replaceItemValue("SendTo", thisdoc.getItemValue("Destinatari"));
tempdoc.replaceItemValue("Subject", "My application");
var tempbody:NotesRichtextItem = tempdoc.createRichTextItem("Body");
tempbody.appendText("Click for open the doc. in client")
tempbody.addNewLine(2);
tempbody.appendDocLink(thisdoc);
tempbody.addNewLine(2);
thisdoc.save(true,true);
tempbody.appendText("click for navigating via web")
tempbody.addNewLine(2);
tempbody.appendText(facesContext.getExternalContext().getRequest().getRequestURL().toString() +
"?action=readDocument&documentId=" + thisdoc.getUniversalID());
tempdoc.send();
thisdoc.recycle();
tempbody.recycle();
tempdoc.recycle();
But at tempdoc.send(); I get Exception occurred calling method NotesDocument.send() null
What is weird, is the fact that for an application on the same server the code is working, I just copy the code and just modified the doc datasource and the SendTo field name. Am I missing something? Thanks for your time.
I forget the issue but there's been reports of this problem I think if a bad character gets into the sendTo.
There's a comment on the email bean XSnippet: http://openntf.org/XSnippets.nsf/snippet.xsp?id=emailbean-send-dominodocument-html-emails-cw-embedded-images-attachments-custom-headerfooter
that said:
The solution that seems to work is to use the method :
emailHeader.addValText(xxx,"UTF-8")
instead of
emailHeader.setHeaderVal(xxx)
I'm not exactly sure how that might translate to SSJS.. but the problem might be with special characters..
Related
I have a suitelet similar to:
How to add checkbox in a list (serverWidget.List) in Suitelet
what would the client script look like for something like this? I'm new to scripting so still getting my head around it. Basically what I would like to do is, if there are checks on the sublist in the suitelet, when you click submit, a couple of fields on the checked records get updated. I have the following in my client script, it seems as though the client script is not able to source the internalID of the 'checked' record from the suitelet (maybe missing something to do with context?):
function SaveRecord() {
var isChecked = "F"
var lineCount = nlapiGetLineItemCount('custpage_sublist_id')
nlapiLogExecution('DEBUG', 'Line Count', lineCount);
if (lineCount>0){
for(var line=1; line<=lineCount; line++)
isChecked =
nlapiGetLineItemValue('custpage_sublist_id','custfield_selected',line);
var siinternalid = nlapiGetLineItemValue('custpage_sublist_id',
'internalId',line);
nlapiLogExecution('DEBUG', 'Internal ID', siinternalid);
if (isChecked =="T") {
var record = nlapiLoadRecord('VendorBill',siinternalid);
record.setFieldValue('FIELD1', 'T');
record.setFieldValue('FIELD2','F')
nlapiSubmitRecord(record);
}
}
return true;
}
Thanks.
I solved the issue by removing the client script altogether and adding a POST (else) element to the suitelet to handle the submit element of the suitelet. If anyone wants to see let me know and I can post up.
Sounds like you've got a workaround. But regarding your initial question, in the context of a Client script you'll typically use:
nlapiGetCurrentLineItemValue
instead of:
nlapiGetLineItemValue
In my document i have multiple "Body" field which contains Rich-Text data as well as attachment files which is of type (Data Type: MIME Part).
My purpose is to only delete the attachment files from my document. I tried this,
if (document1.getAttachmentList("body").isEmpty()) {
requestScope.alist = "No attachments in body";
} else {
document1.removeAllAttachments("body");
document1.save();
requestScope.alist = "All attachments removed from body";
}
where document1 is my data source name, by this code it works properly.
But, i want to retrieve document by
var doc:NotesDocument = database.getDocumentByUNID(context.getUrlParameter("documentId"));
where it does not works.
I had even tried by this code,
var doc3:NotesDocument = database.getDocumentByUNID(context.getUrlParameter("documentId"));
var item:NotesItem =doc3.getFirstItem("$FILE");
item.remove();
doc3.save();
But, here problem is that it also deleting rich text data from document.
Is there any other solution can help me out.
Thanks in advance.
In the first working code you have a the NotesXSPDocument, but in the second example you have the NotesDocument.
may be it is an idea to convert the NotesDocument to a NotesXSPDocument so you can use the first example
To convert it in SSJS this example may help you
https://openntf.org/XSnippets.nsf/snippet.xsp?id=wrap-notesdocument-into-notesxspdocument
What is the difference between the "NotesXspDocument" and "NotesDocument" class in XPages
https://www-10.lotus.com/ldd/ddwiki.nsf/dx/xpages-notesxspdocument-vs-notesdocument.htm
Thanks to the great help on this forum, I was able to get this working:
Displaying Extension Library Dialog box when page loads?
Now what I need to do is not display the dialog box if a parameter is not in the URL. I can do this server side with param.get. How can I get the parameter client side? or is there some work araound?
<xp:scriptBlock rendered="#{not(empty(param.showDialog))}">...
...or, if you want to check for a specific value:
<xp:scriptBlock rendered="#{param.showDialog eq '1'}">...
If rendered evaluates to false, the client script is never sent, so the dialog will not be automatically opened.
Thanks Tim. I could not get your sample to work. I am sure it was something I did wrong. I went with the below. More complicated but it works for me and need to move on:
function getParameterByName(name) {
name = name.replace(/[\[]/, "\\\[").replace(/[\]]/, "\\\]");
var regex = new RegExp("[\\?&]" + name + "=([^&#]*)"),
results = regex.exec(location.search);
return results == null ? "" : decodeURIComponent(results[1].replace(/\+/g, " "));
}
if (getParameterByName('msg') != "")
XSP.openDialog('#{id:dlgMessage}')
I've been trying to figure auto-complete some values from netsuite onto our custom html form.
After a bit of researching, I found this gem: nlapiGetContext (http://www.netsuite.com/portal/developers/resources/APIs/Dynamic%20HTML/SuiteScriptAPI/MS_SuiteScriptAPI_WebWorks.1.1.html)
which should do exactly what it says,
However, when doing a console.log dump of nlapigetcontext()
the following information is displayed, not my current logged in user information
Here is my current test script:
if (window.addEventListener) { // Mozilla, Netscape, Firefox
window.addEventListener('load', WindowLoad, false);
} else if (window.attachEvent) { // IE
window.attachEvent('onload', WindowLoad);
}
function WindowLoad(event) {
alert(nlapiGetContext().getCompany());
console.log(nlapiGetContext());
}
Any help or guidance is appreciated!
Thank you!
Where is this form located? Context will only work if you are logged into the system, so this won't apply for online customer forms, those are considered to be "outside the system".
You can write a Suitelet to retrieve data from an external form if you are only retrieving values.
I use this to get campaign information on an external landing page.
function getCamData(request, response){
if ( request.getMethod() == 'GET' ){
response.setHeader('Custom-Header-CamID', 'CamID');
var camid = request.getParameter('camid');
var rec = nlapiLoadRecord('campaign', camid);
var o = new Object();
o.thisid = camid;
o.promocode = rec.getFieldValue('campaignid');
o.phone = rec.getFieldValue('custevent_cam_1300num');
o.family = rec.getFieldValue('family');
var myString = JSON.stringify(o);
response.write (myString);
}}
You request something like this:
https://forms.netsuite.com/app/site/hosting/scriptlet.nl?script=188&deploy=1&compid=xxxxxx&h=fb8224b74b24907a79e6&camid=8020
And returns something like this:
{"thisid":"8020","promocode":"CAM999","phone":"1800 111 222","family":"12"}
Also you can do server-side posting from an external site to a NetSuite customer online form, it will capture and validate the data as far as it has the entry fields set in NS, this is a great way to avoid using those horrible iframes.
Use these functions
nlapiGetContext().getName()
nlapiGetContext().getUser()
nlapiGetContext().getRole()
nlapiGetContext().getRoleId()
nlapiGetContext().getRoleCenter()
nlapiGetContext().getEmail()
nlapiGetContext().getContact()
nlapiGetContext().getCompany()
nlapiGetContext().getContact()
nlapiGetUser()
nlapiGetDepartment()
For details check http://suitecoder.appspot.com/static/api.html
I'm new to Couchdb just a few week back I git clone the couchdb app called sofa [what and app] . Over the week It was going great but suddenly today I stumble upon something.
Here what I meant
when I browse the Sofa app and try to create a Post without the title
it prompt with and alert box "The document could not be saved: The database could not be created, the file already exists." which was weird as looking at the source I found that the require (in validate_doc_update.js return its custom json error) something like in this format {"forbidden" : message }) with forbidden as key
v.forbidden = function(message) {
throw({forbidden : message})
};
v.require = function() {
for (var i=0; i < arguments.length; i++) {
var field = arguments[i];
message = "The '"+field+"' field is required.";
if (typeof newDoc[field] == "undefined") v.forbidden(message);
};
};
in validate_doc_update.js
if (newDoc.type == 'post') {
if (!v.isAuthor()) {
v.unauthorized("Only authors may edit posts.");
}
v.require("created_at", "author", "body", "format", "title");
inspecting the response state that the json returned was found to be different from the json had it would have been return by the above require function in validate_doc_update.js
here is the json
{"error":"file_exists","reason":"The database could not be created, the file already exists."}
This make be believe that the validation in validation_doc_update.js only execute during updating of document
to Prove this point I try to update a document without the title, expecting that it would return the error but surprisingly the document just got saved
so Here are my Question regarding all the Point I mention above
Does validate_doc_update.js "validate" work only during updation of document
if YES
then
how can I manage to succeed in updating a post without the error [Weird bypassing the Validation Completely] . + How can execute validation on create of a document
if NO
then
What is the Error {"error":"file_exists","reason":"The database could not be created, the file already exists."} that is prevent a document to be saved
Can anyone please share light on all the questions listed here
Yes, the validate_doc_update functions are run only when updating documents (include creation and deletion).
The function you show here will allow a document without a title as long as its type is not "post". If you could include the actual request you attempted, I could confirm it.
Finally, the ""The database could not be created" is because you are attempting to create the database (by doing PUT /dbname/ instead of PUT /dbname/docid, I would guess) when it already exists. Again, if you would include the actual request, I could confirm that too.