Is there any standard library in SuiteScript?
For example I want to use functions like getNLMultibuttonByName() or onMainButtonClick() that Netsuite supports, but I met undefined error when I use this in my own script.
Those functions are undocumented and used internally by Netsuite and are not supported for use in user scripts. For a reference of the Netsuite API, see the SuiteScript documentation (login required).
Remember :
getNLMultibuttonByName() or onMainButtonClick() are Netsuite specific UI functions and are not a part of regular Suitescript.
If you want to simulate the same behavior using a button then probably you can do something like this
function onLoad(type, form, request){
if(type=='view') {
form.addButton('custpage_button','Custom Button',"getNLMultiButtonByName('multibutton_convertinvt').onMainButtonClick(this);return false;");
}
}
getNLMultiButtonByName is an undocumented NetSuite client side function call used by NetSuite. I've successfully used the line of code below in client side scripts to mimic the action of pressing the "Submit" button for example on a Project record. You don't need to attach/reference a library in your script to use the following:
getNLMultiButtonByName('multibutton_submitter').onMainButtonClick(this);
Related
I have a flow, that gets triggered when a file is created in the Documents. The flow will add a column to the document library. The problem is that the modified by field in the Document library always contains the value as my name, instead of showing the user who triggered the flow.
I have already followed this article and seems like that is not working on my end.
After doing those changes, my flow runs fine without any error and giving an output as proceeding.
{
"d": {
"ValidateUpdateListItem": {
"__metadata": {
"type": "Collection(SP.ListItemFormUpdateValue)"
},
"results": [
{
"ErrorMessage": null,
"FieldName": "Editor",
"FieldValue": "[{\"Key\":\"i:0#.f|membership|nk#fdgfsgfs.de\"}]",
"HasException": false,
"ItemId": 1
}
]
}
}
}
But there are no changes in the Document library, it still shows my name in the modified by column as I created the Flow. Even if this worked, I have another question that how can I dynamically find out and add who is triggering the Fow instead of giving a static editor claim in the first Compose step in the above image?
Anyone else faced this issue? Any help is really appreciated.
I do not think it is possible at the moment to dynamically find the current logged in user. you can check out this post
https://powerusers.microsoft.com/t5/Building-Flows/Flow-to-SharePoint-list-item-change-quot-Created-By-quot/td-p/93668
I could solve this issue by using the REST API in the flow itself. This is what I did,
Get the user who called the flow
Update the Modify field by using the REST API in the flow itself
This blog post will help.
How can I change a field on a form when it is initially created, but not when it is later edited? I'm currently using a Client script and coding for this with the pageInit function, but I need to allow my users to manually change the field after it is initially created without the script overriding their changes.
Let me know if more details are needed for what I am exactly trying to accomplish.
As I mentioned in a comment above, I figured this out. Using the type parameter of the pageInit function, I can make events fire on page edit or page creation like this:
function pageInit(type){if(type == 'create'){//do stuff}else{//do other stuff}}
I'm wondering if anyone knows a way to HIDE certain fields (such as costs) from certain Netsuite roles if they are not permitted to see costs.
I can prevent users changing sell prices without the proper authority with nlapiDisableLineItemField during PostSourcing and validateline etc...
But with cost fields, I'd like to HIDE them if the user does not have COST access. I realize I can do this by creating a separate form that does not include costs, but if I can hide information via the script, it means less duplication of effort down the track with other things I have in mind.
You can use a beforeLoad userevent script to hide body level fields (but, it is not possible to do the same for line item field, as there isn't any API on nlobjform to allow that. For sublist/lineitem fields You will have to write a client script validations or remove the field from the form like you have been already doing as you mentioned in your question).
In you beforeload user event script you get access to form and then use something like below to hide body level fields.
function beforeLoadEntryFunction(type, form)
{
if(nlapiGetRole() === 'NON_ACCESSIBLE_ROLE_ID'){
form.getField(YOUR_BODY_FIELD_ID).setDisplayType('hidden');
}
}
Edit:
For sublist/lineitem fields create a client script with code as
function clientScriptEntryFunction(type, form)
{
if(nlapiGetRole() === 'NON_ACCESSIBLE_ROLE_ID'){
form.getField(YOUR_BODY_FIELD_ID).setDisplayType('hidden');
nlapiDisableLineItemField(SUBLIST_ID, LINE_FIELD_ID);
}
}
And in before load user event use form.setScript(YOUR_CLIENT_SCRIPT_ID) as you already have access to the form object.
Remember, client script should be a global client script
If your purpose is purely aesthetic, you can do a Client side onLoad script and hide the fields via jQuery, you can do a select by name which wouldn't change even on version upgrades.
The jQuery library is included on NetSuite.
I have a NetSuite Suitelet script that is listing all of a customer's credit cards so that they can edit the cards themselves.
I would like to remove the "remove" button from that sublist, if possible. I've looked all over the NetSuite support site, with no luck. Has anyone encountered this before?
Below is the code that I have:
var creditCardSublist=form.addSubList('custpage_credit_card_sublist','inlineeditor','Current Credit Cards');
/* this does not work */
form.removeButton('custpage_credit_card_sublist_remove');
/* this does not work either*/
creditCardSublist.removeButton('custpage_credit_card_sublist_remove');
Thanks for any assistance with this.
Actually client side is what you have to do.
You create a client script to go along with your suitelet.
use form.setScript... to associate it.
in the client script create an initLine function. That function can use jQuery (automatically included by Netsuite) to find and remove the Remove button.
This is a hack but Netsuite doesn't have any API for manipulating those lists
addSubList(name, type, label, tab) takes a type parameter, which decides the sub list type.
editor - An edit sublist with non-inline form fields
inlineeditor - An edit sublist with inline fields
list - A list sublist with editable fields
staticlist - A read-only segmentable list sublist.
So you might want to use a staticlist type.
use this jQuery in relevant client script.
jQuery(".uir-insert").remove();
jQuery(".uir-remove").remove();
jQuery('#custpage_so_sublist_insert').hide();
jQuery('#custpage_so_sublist_remove').hide();
Note:
you can only use jquery in clienscript so you must create client script along with suitelet script.
Which is the best way to display a custom form for each new document being added to a specific document library?
I want the user to have some control over some actions that adding the document will cause - specifically, tasks created for users in a Task List, which the contributing user will have to OK before committing.
Is the best way to do this via a Workflow or an event handler?
Regards
Moo
For SharePoint server 2007:
A combination of a specialised content type and an event handler will give you the most control of the process (easier to debug too). A workflow is best for "easy" actions and is harder to make complex actions happen.
A workflow allows for more flexibility in assigning the workflow to different libraries by site admins.
Roll your content type and event handler into a feature that can be deployed. Assigning the content type to a list will allow you to take any data created by the standard form (remember you can create custom fields for really complex/custom data entry) and take any action required, including creating tasks based on the item.
Thanks for the answer, thats the route I was investigating but unfortunately I haven't found a way to make it work for Document Libraries - only Lists.
The problem I have come across is that aving a SPUtility.Redirect in the ItemAdded, ItemAdding, ItemCheckingIn or ItemCheckedIn event on the document library doesn't do anything at all, because there is no page related to the events - its all backend code being fired that is not linked to a web context, because its not the webpage doing the heavy lifting at that point but the Office integration.
All of the examples I have come across seem to rely on the fact that the EditForm.aspx or NewForm.aspx page is being displayed at the time the event is fired, which of course is not the case here.
This also leads to the problem that I cannot extend the EditForm.aspx or the CheckIn.aspx page to do what I want either, because Office 2007 circumvents both of these.
So, the only option left open to me at the moment is doing it through a workflow :/
Any further tips would be fantastic.
I may not understand your question, but is this close to what you're trying to do?
http://msdn.microsoft.com/en-us/library/ms550037.aspx
If not, in what way does this come up short?
A new "Content Type" with its New Form url set to the appropriate value should do the trick.
Unfortunately you may not be able to achieve what you are trying to with an Event Handler or a Workflow. You would ideally want the form to show up as soon as the user adds a new item to the library and a custom content type will do the trick.
Create a new Content Type. (Derive it from the existing Content Type)
Remove the default content type from the doc library.
Using the Object Model to set the New Form url to an aspx page or an Infopath form you've created.
Kind regards,