Source of insert\update operation - acumatica

Say you customized a RowPersisted event. How would you know if the operation was invoked thru an API or not ? I only want to execute my customization if the update was done thru REST API for example.
TIA

try this, If you want your code to be executed only from API calls, you can add your code inside this if condition
if (Base.IsImport)
{
//your code
}

Related

ModifiedBy field in SharePoint Document library is always my name instead of the one who triggered the flow

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.

REST API - execute multiple actions

Currently trying to work out how to use REST API to execute an action.
I added the ReverseInvoice action from Bills screen on my endpoints. And seems execute fine. Unfortunately, executing an action does not return a result e.g. 204 No Content. I'd wish to extract the RefNbr of the Debit Adj. raised.
Second problem is how do you stack actions or call series of actions ? The raised Debit Adj is not Released. So it seems ReverseInvoice & Release need to be executed at the same time. Plus, I also need them to be allocated against each other automatically.
I've got a feeling the REST API is not the way to go with this one.
Cheers and thanks for responses.
Unfortunately, you're correct on both points: Acumatica's Contract-based API (both SOAP and REST flavors) doesn't allow you to get the entity that is a result of an action (you can only get the status of action invocation), and if you want to chain a sequence of action you'll have to do that manually from the client (call one action, check for the status, call the second one, check, raise, rinse, repeat). Or you can write a customization with a custom action that call two actions in sequence, and call that from the API.

Is there any library getNLMultibutton involved in?

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);

NetSuite Record Creation Event

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}}

What is base.ItemAdded(properties);?

For event handling code the following code comes up as default:
base.ItemAdded(properties);
Can anybody tell me what it is used for?
Thanks,
Amit
This event handler notifies you of when an item has just been added to a sharepoint list so that you can do some post-processing on the item. Use ItemAdding() if you want need to make changes to the item before it is posted to the list such as incrementing a unique record ID.
Basically it calls it base Class's ItemAdded method which in turn calls another method BaseItemEventReceiver.
What this method does is set properties.Status = SPEventReceiverStatus.Continue;
This just means that the event is allowed to continue (not cancelled).
As for me I always replace the line "base.ItemAdded(properties);" with my code and it works perfectly fine.

Resources