Netsuite Restlet - inserting sales order - netsuite

I'm trying to insert in sales order through suitescript and I always get an error on 'Location'.
here's my request
{
"recordtype" : "salesorder",
"entity" : "142832",
"location" : {
"id":"395"
}
}
and this is the response
{
"error": {
"code": "USER_ERROR",
"message": "Please enter value(s) for: Location"
}
}
and I tried changing the location value for example
"location" : "390"
the result would be
{
"error": {
"code": "INVALID_KEY_OR_REF",
"message": "Invalid location reference key 390 for subsidiary <NULL>."
}
}

This error is occurring because the location is not "accessible" by the subsidiary associated with the customer. Subsidiaries are defined on the customer level, not on the sales order. You need to ensure the subsidiary chosen on the customer is contained within the subsidiary hierarchy of the location. To fix the issue you need to adjust the associated subsidiary of the location.
Here's more information on how to fix a very similar issue with items:
https://dashboard.suitesync.io/docs/resolving-errors#im-seeing-a-invalid-item-reference-key-123-for-subs

Related

Want to pass multiple enum values for PageSpeed Insights API

I'm trying to use PageSpeed Insights API. The API Reference indicates that I can pass multiple category values when calling the API.
I issued the below command. Category values are separated with commas.
curl 'https://pagespeedonline.googleapis.com/pagespeedonline/v5/runPagespeed?key=<my key>&url=<my url>&category=ACCESSIBILITY,BEST_PRACTICES,PERFORMANCE,PWA,SEO'
The API responds with the below JSON.
{
"error": {
"code": 400,
"message": "Invalid value at 'category' (TYPE_ENUM), \"ACCESSIBILITY,BEST_PRACTICES,PERFORMANCE,PWA,SEO\"",
"errors": [
{
"message": "Invalid value at 'category' (TYPE_ENUM), \"ACCESSIBILITY,BEST_PRACTICES,PERFORMANCE,PWA,SEO\"",
"reason": "invalid"
}
],
"status": "INVALID_ARGUMENT"
}
}
I have no idea how I can pass multiple category values. Does anyone know how to do that?
Pass as seperate parameter rather than comma seperated.
curl 'https://pagespeedonline.googleapis.com/pagespeedonline/v5/runPagespeed?key=<my key>&url=<my url>&category=ACCESSIBILITY&category=BEST_PRACTICES&category=PERFORMANCE&category=PWA&category=SEO'

How to update a PO Receipt line's PO number via API

When I call the Acumatica REST API to update a PO Receipt, the PO Number field on the detail line is not updating. I'm just doing a PUT to the Default/17.200.001 endpoint, including a detail line. The PUT is successful, but the response returns an empty PONbr and POType on the detail line, and those fields are not updated. Are these fields read-only for some reason? How can I resolve this or override it so that these PO fields will update?
Update #1 3/22:
Per the response below, I tried putting these values in the insert instead of the update, but now I get a different error: "PO Error: Quantity must be greater than 0", and "PurchaseReceipt.Details[0].ReceiptQty: Quantity must be greater than 0". However, the ReceiptQty is there and is greater than 0.
Update #2 3/22:
You should be able to duplicate it with very simple steps:
Create a PO with Vendor, which defaults Location.
Add a PO Line with InventoryID, which defaults the line type and Warehouse
Enter the Order Qty
Save PO
In Postman, PUT similar JSON to what I supplied below for a PO Receipt, specifying a detail line with the referenced Inventory ID, PO Order Nbr, PO Order Type, Line Nbr, PO Line Nbr, Receipt Qty, Warehouse
The response is an error “PO Error: Quantity must be greater than 0”, “PurchaseReceipt.Details[0].ReceiptQty: Quantity must be greater than 0”
Here is sample json for the insert:
{
"Date": {
"value": "2019-03-22T00:00:00-04:00"
},
"Details": [
{
"InventoryID": {
"value": "0010006"
},
"LineNbr": {
"value": 1
},
"Location": {
"value": "01P"
},
"POLineNbr": {
"value": 1
},
"POOrderNbr": {
"value": "005554"
},
"POOrderType": {
"value": "RO"
},
"ReceiptQty": {
"value": 5
},
"Warehouse": {
"value": "002"
}
}
],
"PostPeriod": {
"value": "032019"
},
"VendorID": {
"value": "CVS TRADE"
}
}
Update #3 3/24:
To try to get around Acumatica forcing ReceiptQty to 0, I tried adding a POReceiptLine_ReceiptQty_CacheAttached handler, without the PXDBQuantity, PXDefault, and PXFormula attributes to try to prevent it from getting zeroed out. That gives me a SQL error: "Incorrect syntax near 'INTranInTransit_INTransitLineStatus'" - whatever that means.
The logic there is that when you insert a Purchase Receipt detail line, if you specify the information about the Purchase order then the line will be added with a reference to original Purchase Order in the form of the PONbr and POType.
After the line is inserted the behavior through the web services is the same as the one on the screen, the PONbr and POType are read only field and cannot be modified.
During the insertion the parameter that are required to insert the Purchase Order Line properly are the PONbr, the POType and the POLineNbr.
Update
In certain case due to the complexity of an operation a special adapter was created in order to cover a specific scenario.
In this case the adding of a detail line to a purchase receipt is one of these scenarios.
So only some specific values are required and the rest will be taken from the record in the system.
I think in your case that since the Purchase Order Line is/are already present on another Purchase Receipt, they have a Open quantity of 0 which is then put as the value for the Receipt quantity. Unfortunately this then trigger an error since the receipt quantity in a purchase receipt cannot be 0.

Modify Stripe subscription status

I have been trying to modify the subscription 'status' from 'trialing' to 'active' once the user buys our standard subscription but it doesn't recognize the parameter 'status'.
Post URL : https://api.stripe.com/v1/subscriptions/sub_DlwSiqrLvSArgV
Request body:
{
"Status": "active",
"items": {
"0": {
"id": "si_DlwSpUvFPN6Mje",
"deleted": "true"
},
"1": {
"plan": "plan_Dk4I92tnE0cmXS"
}
}
}
Response:
{
"error": {
"code": "parameter_unknown",
"doc_url": "https://stripe.com/docs/error-codes/parameter-unknown",
"message": "Received unknown parameter: Status",
"param": "Status",
"type": "invalid_request_error"
}
}
I'm not sure if I'm putting the status in wrong place or if i need to add some other additional parameter(s) to change the status.
The status property is calculated by Stripe and it's not something you can set yourself. It is not in the list of parameters for the Update Subscription API either.
If you want to move a subscription from 'trialing' to 'active' you have to explicitly end the trial period by passing trial_end: "now" as documented here. This will automatically charge the customer the expected amount and if the charge succeeds it will switch your subscription to active at the same time.

How to filter SharePoint list items by Created by in Microsoft Graph?

I'm trying to get a collection of list items from a SharePoint through Microsoft Graph, which I want to filter by CreatedBy.
Requesting: https://graph.microsoft.com/v1.0/sites/{siteid}/lists/TeamRequests/items
Returns:
{
"#odata.context": "https://graph.microsoft.com/v1.0/$metadata#sites('{url}')/lists('TeamRequests')/items",
"value": [
{
"#odata.etag": "\"56ad787e-bd69-464a-b5da-dd953e40d7c4,13\"",
"createdDateTime": "2018-02-26T08:34:26Z",
"eTag": "\"56ad787e-bd69-464a-b5da-dd953e40d7c4,13\"",
"id": "11",
"lastModifiedDateTime": "2018-03-22T13:20:03Z",
"webUrl": "{url}/Lists/TeamRequests/11_.000",
"createdBy": {
"user": {
"email": "{email}",
"id": "9c9cbb67-c049-4a2d-845d-6c5ca2300041",
"displayName": "{Name}"
}
},
"lastModifiedBy": {
"user": {
"email": "{email}",
"id": "9c9cbb67-c049-4a2d-845d-6c5ca2300041",
"displayName": "{Name}"
}
},
"parentReference": {},
"contentType": {
"id": "0x01005F15F8133495554D834FF82F187AD0630002133A9CCDE4494D8CB2206D7D6453D6"
}
},
Now I'd like to filter this request for createdBy, either Id, displayName or email address. I tried ?$filter=createdBy/user/email eq '{email}' and similar requests for id or displayName. They all return
{
"error": {
"code": "generalException",
"message": "An unspecified error has occurred.",
"innerError": {
"request-id": "492e3bde-05fe-4484-a475-435ff0aa70b6",
"date": "2018-07-23T07:41:46"
}
}
}
So how to accomplish this filter? Is it even supported?
Even though it sounds like a straightforward query, i have not come up to anything more simple then the following solution:
It seems filtering by user field is not supported except the case when user id is provided, that's the reason why the solution consists of two steps:
1) First, we need to determine user Id by Email , for that purpose the following query could be utilized:
https://graph.microsoft.com/v1.0/sites/root/lists('User Information List')/items?expand=fields(select=Id,Email)
*where User Information List system list stores user properties including Id and Email properties *
2) Once the user Id is resolved, the final query to filter items by user id could be applied:
https://graph.microsoft.com/v1.0/sites/{site-id}/lists('list-name')/items?filter=fields/<user-field-name>LookupId eq '<user-id>'
where
<user-field-name>LookupId is a field which is getting exposed in addition to user field, in case of Created field the name should be AuthorLookupId
Example:
https://graph.microsoft.com/v1.0/sites/root/lists('TeamRequests')/items?filter=fields/AuthorLookupId eq '10'
Note
In some cases the following error is returned Field ''
cannot be referenced in filter or orderby as it is not indexed.
Provide the 'Prefer: HonorNonIndexedQueriesWarningMayFailRandomly'
header to allow this, but be warned that such queries may fail on
large lists.
In that case the following request header needs to be applied:
Prefer: HonorNonIndexedQueriesWarningMayFailRandomly
When I tried to access User Information List list. There is an error with list not found.
So since in my case, first I filtered list data based on status value and next step got the logged in user display name and filtered listitems based on display name.
I'm using #pnp/graph
Filter list data with status filter
let resultsList = await listItemsQuery.filter("fields/RequestStatus eq 'Approval Pending'").expand("fields").get<MicrosoftGraph.ListItem[]>();
Get Logged-In Profile:
const profileQueryEndPoint = new GraphQueryableCollection(graph.me, "/");
Select displayName property from above result
let profileData : User = await profileQueryEndPoint.select("displayName").get <User>();
console.log('displayName : ' + profileData['displayName']);
Filter ListItems with createdby Field by passing profileData['displayName']
let filterUserCreatedRequests: MicrosoftGraph.ListItem[] = resultsList.filter(ListItem => ListItem["createdBy"].user.displayName === profileData['displayName']);
Display filtered results
console.log('filterUserCreatedRequests : ' + JSON.stringify(filterUserCreatedRequests));
I'm giving all the steps for your reference. But above code can simplified more.
Hope this helps someone :)

Azure Graph API Nested Group Membership

I need to query a user's nested group membership. memberOf only give direct group membership. When I try getMemberGroups, getMemberObjects, checkMemberGroups, etc. using version 1.5 or 1.6, I'm getting this:
{
"odata.error": {
"code": "Request_BadRequest",
"message": {
"lang": "en",
"value": "Method Not Allowed"
}
}
}
Any ideas on how to fix this?
You might be making a GET request. According to documentation, you need to make a POST request for getMemberGroups.
URL:
https://graph.windows.net/domain.com/users/first.last#domain.com/getMemberGroups?api-version=1.6
Request body:
{
"securityEnabledOnly": true
}
Here the parameter defines if you want only security groups back, or if it should return Office 365 groups too.

Resources