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.
Related
I had an old SuiteScript 1.0 script that added any number of rows to a sublist of an Item Fulfillment when a button was pushed. In that script when i was done I was able to call
nlapiRefreshLineItems('recmachcustrecord_contents_sublist');
What that did was refreshed the subtab contents so it would show the up to date list with the new rows added (or removed).
Anyhow it seems that call does not have a 2.0 equivalent. I noticed I could go and refresh the whole page with the browser RELOAD and it would of course show correctly. Any suggestions on any ways to facilitate that updated sublist via scripting?
via script you have to write a function and trigger it yourself.
You can get the field at pageInit using context.currentRecord.getField and then use the same to setSelectOption
I'm hoping someone can help. I recently wrote a SuiteScript 2.0 project. The primary suitelet displays transaction/customer info in a sublist that has a SublistType of LIST. Right now we're displaying 750 records in the list at a time, but there can potentially be hundreds or even thousands of additional records, so the users want to have a Next and Previous button that will allow them to cycle to the next page of results.
The problem is that I cannot seem to update that sublist for the life of me. The fields on the sublist are all text fields except for one checkbox. Inside of a CLIENT SCRIPT, I've been trying things similar to the code below. (I removed all but one of the setCurrentSublistValue calls to shorten the code):
var currentRec = currentRecord.get();
currentRec.selectLine({
sublistId: 'custpage_studstatement',
line: 0
});
currentRec.setCurrentSublistValue({
sublistId: 'custpage_studstatement',
fieldId: 'custpage_show',
value: false
});
currentRec.commitLine({sublistId: 'custpage_studstatement'});
It will spin through all of the sublist items, but ONLY the checkbox gets updated. None of the text fields change, and no exceptions are thrown.
If I change the sublist to type EDITOR, I can update all of the fields on the line without a problem. It basically behaves they way I want it to. Also, if I change the FieldDisplayType on any of the text fields, I can then update those individual fields, but neither of those options are acceptable. We don't want the users to be able to edit those fields/lines like that. The LIST sublist is the one we want, but I'm beginning to think you cannot update LIST sublists from a client script, even though the docs suggest that you can. (although it's not definitive. The docs are a bit sketchy)
So I guess I'm mostly just looking for a high level answer, because I'm not sure I'm even approaching this correctly. If you have a custom sublist that is just a LIST, how would you add the ability to page through to the next set of results? Should updating that sublist be done in the client script? If so, how? Or should it be in the suitelet? And if so, how? (I've tried some various things in the suitelet as well, but I'll omit that to keep this from getting any longer) Thanks in advance
I am making a few assumptions here:
Your suitelet creates a custom page - it has a sublist. The sublist is a form.sublist. and inside it are fields, sublist.addfields.
What you can do is use sublist.setSublistValue and it can populate the whole sublist.
Now, It depends on how you obtain the values of your sublist - you can have additional fields in the body - the bodys will define a filter that filters this search. This will scale down results shown in the page a lot to achieve the result you have.
You can indeed have next and previous page - of which you have your search object, and your next page/previous page button will impact your results.getRange() function - instead of for example getRange({start:0 end:1000}) to be getRange({start:1000 end:2000}) greater and beyond that. (This isn't the only way, but how I imagine I would do it)
Either way, how you get your dataset - a search.create will be in your suitelet, the getRange will be in your suitelet. How you setSublistValue will be in your suitelet. How you create your buttons will be in the suitelet.
But, the function that the button triggers will be in your client script, loaded via form.clientScriptModulePath = './xxx.js'; Something like that. This client script can trigger scripts via url.resolveScript, and trigger the suitelet to add params. Passing some parameter to indicate which 'page' to load (first set of results..second set.. etc.)
Hope this will point you in the right direction!
You can not update the sublist in suitelet using Client Script and with sublist being LIST type.
You can create Next and Previous button and on click of these button you can again hit the suitelet url from ClientScript and passing the pagenumber parameter and displaying the sublist dataset in forward and backward direction depending upon the value of pagenumber.
For eg:- if you are displaying 750 pages at one time then the first time you press Next your pagenumber parameter will be 2 and you will show next 750 entries in the page.
Is there a way to access a custom sublist on a custom record via suitescript? I have a record that users will enter criteria into that will then populate a bom in the sublists section via a saved search. Is there a way to access this data? When I try to run currentRecord.getSublists(), it says that it is not a function.
Any help is appreciated. Thanks!
Just in case people still run into this issue, it's a matter of dynamic vs static records.
currentRecord in a User Event is both a static record and cannot be "saved" (i.e. if you want to make changes in an afterSubmit method).
You'll want to record.load in dynamic mode to get what you are looking for.
var linect = rec.getLineItemCount('recmachcustrecord');
I am having a problem finding out an id of a sublist. I am using SuiteScript 1.0. For instance, I need to list the components of an assembly item record, how do I find out the list id and the "type and field name to use in the nlapiGetCurrentLineItemValue or nlapiGetCurrentLineItemValue methods. What I am looking for is how now and in the future when presented with a sublist, do I go about finding the ids of the objects needed. I have internal ids turned on but that does not help in the sublist view. What is the best way to get this information when I need it? thanks for any help you may give.
You can use nlapiGetAllLineItems() to get an array of all the sublists. You may need to load the record first and do record.getAllLineItems()
I have found the most useful method for figuring out internalids is to run nlapiLoadRecord(..) in your Browser Console and examine the resulting object. Another trick is the add &xml=T to the end of the URL of the record, which displays the record in XML format. NetSuite also documents most of the internalids in the Records Browser.
In this case you use console in Google Chrome. Open the Specific Assembly Item Record page and Press F12 and select console.After give following code
nlapiLoadRecord('assemblyitem', 90088(id for specific record));
after show result in console. Select linefields and Item. Now it show the fields of sublist. If You have any doubt let me know.
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.