Dynamics Navision 2018 - Insert Sales Order Discount using Web Services - microsoft-dynamics

I have Navision Dynamics 2018 Update 10 which has Sales Orders exposed as a SOAP web service.
The problem raises when we want to set Invoice Discount which is not available in SO header and it appears in SO Lines as read only property :(
How could I set the invoice discount using the Web Service.

I use the following code: You have tu set Invoice_Discount_AmountSpecified false ; if you want to set a number in Invoice_Discount_Amount
foreach (var linea in resLineas)
{
order.SalesLines[contLineas].Invoice_Discount_AmountSpecified = false;
pedido.SalesLines[contLineas].Invoice_Discount_Amount = 5;
contLineas++;
}
servicio.Update(ref order);

Related

Cannot access the push dataset from power bi custom connector

I've created a custom connector that uses authorization flow to connect to third-party APIs and I use an enterprise gateway to schedule the refresh for the dataset. The issue with that is, that the old dataset is being replaced by the new dataset after every refresh. I have scheduled the refresh to run every 1 hour. So at the end of the day, I lose all the reports. So as a solution for this, I created a push dataset which I believe is backed up by a DB, and using the rest API I'm pushing the refreshed data to the push dataset. Below is the code for that.
pushdataset = (data) =>
let
headers = [RelativePath = "https://api.powerbi.com", IsRetry=true, Headers = [
#"Content-Type"="application/json", Accept="application/json"
], Content = Json.FromValue(data)],
response = Web.Contents("/beta/77777/datasets/66789900/rows?key=ccccc", headers),
in
response;
expandTable = () =>
let
TableFromList = Table.FromList(reportEntries, Splitter.SplitByNothing(), null, null, ExtraValues.Error),
ExpandColumn = Table.ExpandRecordColumn(TableFromList, "Column1", {"category"},{ "Column1.category"})
in
ExpandColumn
When I execute the connector I get
"Access is forbidden 403" error. It seems like a simple HTTP request, I can access the dataset using the python code and also from the postman.
I'm stuck with this for a long time. How do we connect to the push dataset from the custom connector? Also if there are other ways to keep the existing data and append new data to the dataset after every refresh, please let me know.
Example:
Scheduler runs at 9am
Data stored in the dataset
Category Total Item
Bike 1
Mobile 2
Scheduler runs at 10am
Data stored in the dataset**
Category Total Item
Watch 10
Books 2
What is expected:
Category Total Item
Bike 1
Mobile 2
Watch 10
Books 2

Display Count of Users based on Multiple slicer values Power BI

I am working on a Viewership table which tells numbers of customers watches asset. There are two asset filters. One for watched and one for not Watched. Based on the asset filters, I need to display number of customers who watched the show & customers who didn't watched the show. Below is the method I have used.
First, created a new table "Asset":
This table contains unique assets and used it to create a slicers that affects DAX measure but does not affect the visual (table). Asset table disconnected from the Viewership table (no relationships).
Created the copy of the above table for not watched assets and named it as asset_1
below is the viewership table.
Created below measures to get the customers who viewed the selected asset (from first slicer) & he customers who not viewed the selected asset (from second slicer) &
Watched Status =
VAR Selected_Assets = ALLSELECTED(Asset[asset_id])
VAR Customer_Assets = VALUES(Viewership[asset_id])
VAR Assets_Watched = COUNTROWS(INTERSECT(Customer_Assets, Selected_Assets))
RETURN
IF(Assets_Watched > 0, "Watched", "Not Watched")
Not Watched Status =
VAR Selected_Assets = ALLSELECTED(Asset_1[asset_id])
VAR Customer_Assets = VALUES(Viewership[asset_id])
VAR Assets_Watched = COUNTROWS(INTERSECT(Customer_Assets, Selected_Assets))
RETURN
IF(Assets_Watched > 0, "Watched", "Not Watched")
I got below result
after applying below filters in the visual filter pane I can see the desired result.
Watched Status= "Watched",
Not Watched Status = "Not Watched"
Now I got a Requirement to show total number of customers (Instead list of customers) with above filter criteria. For e.g: In the above case customer count is 1.
I have tried below measure.
Customer Count = CALCULATE(DISTINCTCOUNT(Viewership[customer_id]),FILTER(Viewership,([Watched Status]= "Watched") &&left([Not Watched Status],3)="Not"))
The expected result is 1 (Customer ID: 4). But I am getting result as 2. Could someone help to identify the issue here?
What you can do is drag teh customer_id in the visual as column and ensure it is set to count distinct.
Select your visual, go the the vusialization panel under values you can see the column, click on arrowdown, popus will show:

How to apply Entity_Filter as OR in Dynamics NAV WebService

I am consuming a Dynamics NAV 2009 WebService (SOAPish). Specific I am talking about the ReadMultiple method MSDNA
The filterArray takes an array of Entity_Filter objects. Each Entity_Filter has a Field and Criteria property.
Now I want to know, how I can apply the filters as OR not and.
For Example I am passing two filters:
Entity_Filter { Field: "Name", Criteria: "*banana*" }
Entity Filter { Field: "Color", Criteria: "yellow"}
If I send this to the ReadMultiple I get all entries that have "banana" as part of the name AND the color yellow. What do I have to do, to get all Entries that have "banana" as part of the name OR the color yellow?
Unfortunately, there is no way to apply an 'OR' filter on a record. ReadMultiple method applies filters the same way C/AL methods SETFILTER or SETRANGE do. It has to be done in two separate requests.
On the second thought, you can do it in a single request, but with an OData service using Linq:
NAV nav = new NAV(new Uri("http://ServerName:Port/DynamicsNAV71/OData/Company('Your Company Name')"));
nav.Credentials = CredentialCache.DefaultCredentials;
var items = from i in nav.ItemsList where i.Name.Equals("Banana") || i.Color.Equals("Yellow") select i;
Where 'ItemsList' is an OData web service of type 'Page'

Return NetSuite "tranid" When Adding a Sales Order

Using the NetSuite web service I am creating a sales order. The result that comes back only contains the internalId for the sales order. The email that goes to the customer shows the tranid however (shown as the "Order Number"). Is there a way to return the tranid when creating the sales order so that I don't have to make a second API call to get the order details?
No.
simplest thing is to:
var id = nlapiSubmitRecord(soRec);
var tranId = nlapiLookupField('salesorder', id, 'tranid');

Dynamics Nav (Navision) webservice ReadMultiple date filter

Using the Navision webservices, how can you filter by a date.
i.e. Within a SalesHeader table there is an "ExportedDate". I would like to find all SalesHeaders where the ExportedDate has not been set or were exported on a particular date.
It seems that whenever we set a filter on a date field, then the webservice will either return all rows or no rows.
This can be done. You have to use the same filter expression as you would use in the Nav Client:
01012011.. would be all dates from 01.01.2011
..01012011 would be all dates to 01.01.2011
01012011..03012011 gets all dates between 01. and 03.
After publishing page 42 (Sales Order) as a web service in NAV, I added a web reference to the newly created web service in my Visual Studio project. In the C# code, I create a new instance of the service, and tell it to use the default credentials:
SalesOrders_Service salesOrdersService = new SalesOrders_Service();
salesOrdersService.UseDefaultCredentials = true;
Then I instantiate a filter, and set the field and criteria:
SalesOrders_Filter filter = new SalesOrders_Filter();
filter.Field = SalesOrders_Fields.Document_Date;
filter.Criteria = "01-31-14|''"; // specific date (MM-dd-yy) or empty
The filter instance is then added to a new array of SalesOrders_Filters before passing the latter to ReadMultiple:
SalesOrders[] salesOrders = salesOrdersService.ReadMultiple(new SalesOrders_Filter[] { filter }, null, 0);
On my machine, this returns two orders whose Document Date is 31 January 2014, and one order with a blank Document Date.