Netsuite: How to getDataCenter in SuiteScript - netsuite

I wish to know how to get dynamic data center url.
I have checked in nets and knew that getdatacenterurl only applicable for REST while I wish to do the same in Suitescript.
The reason for this is because currently I am hardcoded the data center in URL and this will not work if the customer change their data center in future.
I know nlapiResolveURL only help to generate the later part of URL and we still need to define the base domain at the first place.
Any helps?

A little hackish but you could use nlapiResolveURL to ask for the external URL of a Suitelet and then replace forms with system and then slice the first part before app. Something like this:
var externalURL = nlapiResolveURL('SUITELET', 'customscript_xxxx', 'customdeploy_xxxx', true);
externalURL = externalURL.replace('forms', 'system');
var dataCenter = externalURL.slice(0, externalURL.search('app'));
Note: The suitelet doesn't need to be public, you can use an internal one and it should still return the first part of the url.

Related

xpages open pages using [NRIC] Field

Question here, may i know using this way to open existing document is totally wrong, or i miss out some part?
Cuz currently not be able to open existing document.
Let say i already have the "document" inside with NRIC 851013-13-5125
Below is the code to get DocumentID
var vw:notesView = database.getView("Request sort by nric used for docID");
var doc:NotesDocument = vw.getDocumentByKey(document1.getValue("NRIC"), true)
if (doc!=null){
return doc.getItemValue("docID")
}
Desmond,
beside a HUGE security hole - displaying data based on an NRIC only (which is almost public data, since you use it everywhere to sign up for membership, discount cards etc.
You should change a few things:
Bind you entry box to a scope variable, not a document, so instead of document1.getValue("NRIC") you use viewScope.NRIC
You don't need to go after an item, but use doc.universalid, or better have that as a column in the view, so you could use #DbLookup(....)
Even better: you could simply redirect the URL to open /yourdb.nsf/byNRIC/[S12345678X] having a view byNRIC that is sorted by NRIC and has in the form property the XPage to open
Having said that: PLEASE(!!!) implement proper security. Singapore's legislation is VERY specific on data protection. You might want to read up on it here: https://www.pdpc.gov.sg/legislation-and-guidelines/overview

Designing an express API with user-created custom paths conflicting with other api end points

In my express app, a user can create a profile, and in doing so can choose a 'CustomUrl' that will be used to generate the url for their profile (example: http://www.myapp.com/profile/customUrl). A profile can also be reviewed, the end points for which might look like:
router.get('/reviews', ...) and router.post('/reviews/new',...)
The API endpoint for fetching a profile is below:
router.get('/:customUrl',...)
While I don't think a user would pick a customUrl like 'reviews', it is possible, and as such, my API endpoint to fetch their profile would be intercepted by the route to get '/reviews'.
I have a few ideas, but I'm generally new to Express, and wasn't sure if one way was better than another. Here are some of them:
1) I can put any end-point with a customUrl path above other end points. This doesn't sound acceptable as then the customUrl path would intercept any requests that are meant for '/reviews' etc.
2) I can validate a customUrl that it is not only unique, but is not an existing end point. This does not seem satisfactory as it does not scale well (would have to update the blacklist every time I add a new end point). It would also be problematic if a user has selected a customUrl that I later want to use for another end point.
3) Separate review out of profile and into its own route. This is probably the best solution, although it would present a lot of work that I'm hoping to avoid (there are other sub-routes name-spaced under '/profiles').
4) Put router.get('/reviews'...) above customUrl, but call next() if there is no req.query ('?sortBy=dateCreate' etc).
5) I didn't mention this earlier because it feels like I'd only be hiding the problem instead of fixing it, but my client-side is in React on a separate port, and so I could configure the router to display the url as .com/profile/:customUrl, but change the API end point to be something like: router.get('/',...) with a queryString of '?customUrl=...' or something like that. The url would then be 'www.myApp.com/profile/:customUrl' but the get request would be to 'api.myApp.com/profile/?customUrl=:customUrl', and the get request for reviews would be 'api.myApp.com/profile/reviews' (or something like that).
Anyway, I have a feeling that I'm missing something pretty fundamental. Any help would be great!
You probably just need to be RESTful with your route naming, for example:
GETing profile:
router.get('/profile/:customUrl', ...)
GETting reviews for a profile
router.get('/profile/:customUrl/reviews', ...)
POSTing a new review (note you don't need a route that says "new" as this can be determined by it being a POST request)
router.post('/profile/:customUrl/reviews',...)
You should use the following verbs for the reasons listed if you are being truly RESTful:
GET - Fetching records
POST - Adding records
PUT - Editing records
PATCH - Performing partial edits (e.g. not sending the whole document)
DELETE - Removing records

autocomplete search field for blackberry

I want to implement the an auto complete feature in an app am currently developing. I would have used the Blackberry native auto-complete field but I want the auto complete list to be gotten from a web server. This feature is being implemented in the search screen of google maps for blackberry.
Please can u give ideas on how to go about this?
I didn't try but I don't see any issue to do that.
You need to add listener for the EditField - getEditField will help you.
After getting list of suggestions, you pack them to BasicFilteredList and set it to AutoCompleteField with setFilteredList.
You should think also about implementation of case when network is not reachable.
Great example from http://devblog.blackberry.com/2010/04/how-to-use-autocompletefield/
After getting your data back from the web server, store the searchable data as String[].
Then you just need the following code to make your AutoCompleteField work:
BasicFilteredList filterList = new BasicFilteredList();
//my query to sqlite database, yours could just be parsed from your webserver or whatever
String[] list = db.getSearchSuggestions(totalCount);
filterList.addDataSet(1, list, "list", BasicFilteredList.COMPARISON_IGNORE_CASE);
final AutoCompleteField autoComplete = new AutoCompleteField(filterList);

In Sharepoint, how do I update a task directly from a link in an email?

I'm just starting to use sharepoint designer and realised there's a lot that can be done to extend the basic features in sharepoint. We have an email alert sent out when a new task is created (by the user) and I want to customise the email so that it also includes a link called 'Assign'. When clicked, I want this link to automatically update the task with the assigned to field for the person that clicked it.
So I think the way to do this would be to hard-code the assign to value in the url behind this link, but I have no idea if this is possible or if there is an easier/better way to do this.
Any advice would be appreciated as I'm a complete beginner.
thanks.
I will not cover "How to modify the contents of an eamil alert" here as that is a seperate question and there are a lot of articles that cover that already.
For the Assigned link :-
You would need to create a custom page (or web part on an existing page) as the destination of your Assign link - this would take the Task ID as a query string param and then update the assigned to with the current user.
You could make this flexible by also taking the ListID but you may want to think about how this could be abused and put appropriate measures in place.
EDIT - in response to comment.
This is top of my head, not checked in compiler. This would have to sit on the same server as SharePoint to work as its using the OM - if you want to use a different server (why would you though) then look in the web services.
private void updateAssignedTo(Guid listId, int itemID)
{
SPWeb web = SPContent.Current.Web();
SPList list = web.Lists[listId];
SPListItem item = list.GetItemById(itemID);
item["Assigned To"] = web.CurrentUser;
item.Update();
}
You're going to have to work out how to get this code into to page or web part (SharePoint Designer is not going to cut it I think, you need Visual Studio) but its a starting point.

Passing form data to another form via url in lotus

I am working on a new web app in lotus/domino. I am newer to lotus/domino programming, so forgive me for not knowing something simple.
What I am trying to do is display a table of information, with one of the columns containing a link. The link is formatted like [http://server/app.nsf/form?openform&ideaNum=1&var2=foo2]
How can I retrieve the information from the url, to get information from a view or a document?
So far I have tried to access the query string in the webQueryOpen event, but lotus runs the agent before the DOM writes to the browser, the query_string isn't available.
I am not sure how else to get information from one form to another in lotus.
Thanks for the help.
-Kris
If you're passing multiple params in the query_string, you can get Domino to do a bit more of the work for you. There's an Function command - UrlQueryString - that can format the params into a list, delimiting at the "&".
E.g. server/app.nsf/form?openform&ideaNum=1&var2=foo2
becomes a list:
openform
ideaNum=1
var2=foo2
To use it, on the destination form create a multi-value text field called something like "QryStringList".
Set it to be computed when composed, and set it's value to #UrlQueryString.
In your WebQueryOpen agent, you can access the params as doc.QryStringList(0), docQryStringList(1) and so on, if you're using Lotusscript.
I'm fairly sure I put this together using info from the IBM/ldd forum, but the exact source is lost in the mists of time and memory, so apologies if I've copied someone's post.
Just as a follow up, I found that you are able to specify an on form variable named the same as QUERY_STRING. The variable is actually a reserved term for Lotus, so Lotus pre-fetches the variable before running the information out the browser.
Due to the pre-fetching, you are able to access the url information during the webQueryOpen event.
I hope this helps someone else looking for the same type of functionality.
-Kris

Resources