I am having trouble with a RESTlet I am working on. I am bringing in a list of individuals who are canceling their service. I need to then go through the list, set their accounts to cancelled, and give a reason why it is cancelled in symptom field called "custrecord_scrapsymptomcode". The symptom field is of type "List/Record" and refers to one of the 20 items in a list called "Symptoms".
I am able to iterate through the individuals and set multiple fields on their record, however I am not able to set the value of the "Symptoms" field, which is supposed to be one of the values from the list. When I attempt to do so I receive an error that "that record is not editable".
I have tried the following strategies so far with no luck:
nlapiSubmitField('customrecord_customer', j, 'custrecord_scrapsymptomcode', s);
and
var rec = nlapiLoadRecord('customrecord_customer', j);
nlapiSetFieldValue('custrecord_scrapsymptomcode', s);
nlapiSubmitRecord(rec);
'customrecord_customer' is the ID of the record type I am attempting to change
'j' is the internal ID of the customer record I am attempting to edit
'custrecord_scrapsymptomcode' is the ID of the field that I am attempting to set
's' is the symptom or reason for cancellation. It should be an item from the list of symptoms. I am not exactly sure why but it seems to only want an integer value.
Is there a better way to set this field value given that it is an item of a list? Is the error I am receiving related to the way I am scripting the record or it this more of a configuration/permissions issue with my system? I should have full admin rights on my system if that is helpful.
Thanks!
Try this :
var rec = nlapiLoadRecord('customrecord_customer', j);
rec.setFieldValue('custrecord_scrapsymptomcode', s);
nlapiSubmitRecord(rec);
nlapiSetFieldValue('custrecord_scrapsymptomcode', s);
This will not work in a restlet - there is no 'current record'.
rec.setFieldValue('custrecord_scrapsymptomcode', s)
will set the value on the record you have just loaded.
As for your error - that might be a permissions error - check the role that the restlet is executing as, and check the default form for that role, and make sure that this particular custom record is editable by that role.
The custom field ids are prefixed with custentity. Please make sure that you are using the correct internalId of the field.
Related
I have a workflow script that transforms a sales order into an item fulfillment when the order is approved.
I can create a subrecord for inventory detail no problem, but in some cases Netsuite will automatically set the inventory detail. In these cases, when I go to add a subrecord, I receive an error on fulfillment submit record.
I have tried for 2 hours and cannot seem to find a way only to verify if the inventory detail is existing. I tried using the examples from the documentation
var invDetailSubrecord = fulfillment.editCurrentLineItemSubrecord('item', 'inventorydetail');
var invDetailSubrecord = fulfillment.viewCurrentLineItemSubrecord('item', 'inventorydetail');
fulfillment.removeCurrentLineItemSubrecord('item', 'inventorydetail');
None of the above commands do anything and are ignored. I don't see any way possible to verify that inventory detail is set before creating it. Viewing the actual data isn't necessary.
You can use nlapiGetLineItemCount on inventory-details subrecord(I am using the same in SuiteScript2.0 and it works) before setting/updating records manually and if you get line count greater than 0, you can safely assume inventory details already exists for the line.
You can check this out for further reading.
I have a SSP script that is attempting to create an invoice for an existing customer with a fee determined by what they applied for. I've set up the fee items under the noninventory items and I have a query which successfully gets the internal ID of the desired item. Next the script attempts to create an invoice and in doing so I am attempting to add the existing item using the internal ID that I have found. The problem is I can't get my head around how this relates, the schema browser shows a field called itemlist which is of type InvoiceItemlist which is made up of invoiceItems.
I take that to mean that I'm working with a sublist but there isn't an invoiceitem sublist type so I'm assuming I'm working with items. So, I've tried various ways to create a new sublist record but most of the examples I can find are how to create a new sublist record where as I just want to instantiate one of the existing items. I've included the snippet of code with my current attempt which isn't working.
var recNewInvoice = nlapiCreateRecord('invoice', {recordmode:'dynamic'});
recNewInvoice.setFieldValue('customform', '104');
recNewInvoice.setFieldValue('entity', stCustId);
// Add Item to invoice
_AddItem(recNewInvoice, stFeeId);
if (stDiscountId) {
_AddItem(recNewInvoice, stDiscountId);
}
try {
objDataResponse.Invoice.Id = nlapiSubmitRecord(recNewInvoice, true, true);
}
catch (ex) {
throw nlapiCreateError('WRITE_FAILED','nlapiSubmitRecord for invoice failed.' + ex.message);
}
// further down I define the function
function _AddItem(recInvoice, ItemID){
recInvoice.selectNewLineItem('item');
recInvoice.setCurrentLineItemValue('item','item',ItemID);
recInvoice.setCurrentLineItemValue('item','quantity',1);
recInvoice.commitLineItem('item', false);
};
I'm using a function for _AddItem because I'm may be adding a discount as well as the fee and I believe they are handled the same. When I run the code with a test case that returns a valid stFeeId I get the following error in the SSP execution log:
nlapiSubmitRecord for invoice failed.Please choose an item to add
*edit added error
*edit: I've updated the code portion to show the changes I've made based on different resources I've found. The original error isn't being generated but I'm getting this new error:
nlapiSubmitRecord for invoice failed.Items you have requested in the record have been deleted since you retrieved the form
When facing a problem like this one, what I generally do is try to create the same record I'm trying to create using the script with the exact same values and by setting the fields exactly in the same order of the scripts.
I do this because, like in your case here, the order is crucial : when creating an invoice, setting the entity will impact what you can use in the other fields, including the Items : so if it is possible that you are trying to use Item1 with an EntityX and Item1 can't be chosen for that EntityX, so the item field will remain empty and you will get that error.
So try creating the Invoice from the UI and see if you can select your item after selecting your entity: if not, then you must fix your configuration, and once you are able to fully create your invoice from UI, you will be able to do so from Script.
I'm passing a parameter to a PowerApp through the calling URL called ID, i.e.
https://web.powerapps.com/apps/powerappid?ID=32
When the app launches I want it to jump from BrowseScreen1 which lists all the Business Cases and go straight to the Business Case with the matching ID (a field from a SharePoint list).
I'm brand new to PowerApps but pretty sure what I need to do is called Deep Linking and I found this tutorial https://powerapps.microsoft.com/en-us/blog/powerapps-deep-linking/ and having read the comments to the article I'm trying to apply it to the OnStart property of BrowseScreen1. I don't really understand how the navigation link in the tutorial is constructed so I'm sure I'm using the wrong Navigation parameters as it always launches the first record in the list ignoring anything to do with the ID. I'm using:
If(Not(IsBlank(Param("ID"))),Navigate(DetailScreen1,
None,{ID:LookUp('Full Business Case For Review'.ID, ID =
Value(Param("ID")))}))
'Full Business Case For Review' is the name of the Sharepoint list and ID is a unique field that gets assigned to each list item.
The tutorial doesn't mention having to change anything on the detail screen but I've also wondered if I need to perhaps change the item properties there as they are currently:
BrowseGallery1.Selected
I'm feeling out of my depth and would really appreciate some help on this!
Thanks,
John
Yes, you need to change the Item property in the detail screen. This is because there is currently no way to select an item in a gallery programmatically in PowerApps.
I normally get around this by using a global variable to store the current item, so you can set BrowseSreen1.OnStart to this
If(Not(IsBlank(Param("ID"))),
Set(CurrentItem, LookUp('Full Business Case For Review'.ID, ID = Value(Param("ID"))));
Navigate(DetailScreen1, None)
)
This will store the item with ID equal to your parameter as a record type variable.
You also need to change the OnSelect property of your BrowseGallery1's template or whichever control is used to navigate to the detail screen. It will need to be something like this
Set(CurrentItem, ThisItem); Navigate(DetailScreen1, None)
Finally set the Item property in the detail screen simply to this
CurrentItem
I'm trying to get an app I'm working on to display all associated user notes for a given Customer record (as it appears on the UI Customer record page in Netsuite proper).
To that end, I've set up a Netsuite RESTlet to return a list of internal ids for associated Note records given a Customer internal id.
I've set up a simple search in the RESTlet script:
function get_notes(params) {
log("GET params", JSON.stringify(params));
var filters = [
new nlobjSearchFilter('internalid', 'customer', 'is', params.id)
];
var columns = [
new nlobjSearchColumn('internalid'),
new nlobjSearchColumn('note'),
];
var search = nlapiCreateSearch('note', filters, columns);
var notes = search.runSearch().getResults(0, 3);
return notes;
}
function log(msg, details) {
nlapiLogExecution('DEBUG', msg, details);
}
The script works as expected, but the problem is that this search ONLY returns Notes for which the author field (which is a user internal id) matches the internal id of the user performing the search. Meaning - you can only search for Notes for which you are the author.
I have been informed that this is a 'feature' of Netsuite for some unfathomable security reason.
I need to be able to get a list of all the associated Note ids, not just those for which the user making the request is the author.
Any ideas on a workaround to get at all the associated Notes? A different way to structure the search? Some kind of secret way to define your own custom Search Joins?
I can't even find documentation on this behavior (blocking Note searches from non-authors). Perhaps someone knows how to override it at the admin level?
I'm not quite ready to admit that this is impossible yet.
NB: User Note is a Note-type record associated with the Customer record, not a field on Customer record, so I can't access it directly from Customer. There is also not a Search Filter or Search Join for Note or User Note.
Using RESTlets you cannot get the notes of other users unless you invoke the RESTlet using credentials/tokens of roles like Administrator/Full Access. RESTlets always runs in the context of current user.
One alternative to do that, if you really got to achieve this any how:
1) Create a user event script on customer which creates a custom record that simulates the functionality of system notes.
2) Make sure that the RESTlet user roles have full level of access on the custom record and make customer as parent of your custom record.
3) In your RESTlet return the custom records.
Basically RESTLETS always run as the user who invokes them.
If you can use a Suitelet for this you can set that up to run as Administrator and can return any Notes you can craft a search for.
Are you actually needing a Restlet ? i.e. Are you calling this from an external application or are you trying to add functionality in the NS GUI? If the latter then you can easily use a Suitelet.
The issue is that everytime an item is edited/changed all the users who are set up to receive updates are notified. I need the workflow to run only when a specific field is changed disregarding the others. For example if my item contains these values (Customer Name; Acc#; Contact Person; Address;) - I need the workflow to work only when the Acc# is changed and only if it is changed, no metter how many times the other fields are changed.
Thanks,
A quick way to do it is to have the workflow store the value each time the it starts, then tell it to wait until the field != the stored value. This may not work in all cases, but it could be enough for your purposes.
You should create an event handler to run on your content type or library. You can then check the before and after properties of the fields you mention. Then use the event handler to initiate the workflow if required.