Except string datatype, not getting any columns populated through AIF Service - dynamics-ax-2012

I have a simple custom table in AX, for which i need to create a Web service so that data could be populated by an external system. I created a Document service with all the Axd* and Ax* objects involved. Next i wrote a simple console application to try populating some dummy data. Interesting thing is i can only get string data type columns populated. Int, Real, Date, Enums etc are not coming through.
In the code below, i am only getting StoreItemId and Barcode columns, as both are strings. Cost is real, ErrorType is Enum, DocketDate is date and none of them get any values. I have discussed this issue with many colleagues and none is aware whats happening. Does anyone know or could point me in some new direction? Thanks a lot.
PS - I have limited experience with AIF and if i am missing something fundamental, please excuse and do let me know. Thanks.
AxdEntity_MMSStagingSalesImport stagingSalesImport = new AxdEntity_MMSStagingSalesImport();
stagingSalesImport.StoreItemId = "9999";
stagingSalesImport.Barcode = "1234546";
stagingSalesImport.Cost = 22;
stagingSalesImport.ErrorType = AxdEnum_MMSImportErrorType.Posting;
stagingSalesImport.DocketDate = new DateTime(2014, 4, 4);
stagingSalesImport.IsDuplicate = AxdEnum_NoYes.Yes;

For some types, you have to specify that you have set the values, so that AX knows the difference between a null value and a value that is set:
stagingSalesImport.Cost = 22;
stagingSalesImport.CostSpecified = true;
stagingSalesImport.ErrorType = AxdEnum_MMSImportErrorType.Posting;
stagingSalesImport.ErrorTypeSpecified = AxdEnum_MMSImportErrorType.Posting;

Thanks for replying Klaas, i like your blog as well.
Should have responded earlier but i fixed the issue.
I didn't try Klaas's option but i had a look at the data policies for the inbound port and found that none of the columns were enabled. I enabled the ones i needed and made most of them required as well. And guess what, that worked. I was expecting that the columns should have been enabled by default.

Related

How to check if an email is a draft, sent or received? (Openedge 11)

I'm trying to create a way to check whether a given email (either from Outlook itself or an MSG file) is a sent, received or a draft email. I got the bit to compare if it was sent or received somewhere else and that works fine but it's the part that determines if it's a draft or not that is the issue. Below is what I have currently.
L-EMAIL = Aspose.Email.Mapi.MapiMessage:FromFile(P-FILENAME).
L-EMAIL-FLAG = Integer(L-EMAIL:Properties[Aspose.Email.Mapi.MapiPropertyTag:PR_MESSAGE_FLAGS]:ToString()).
IF L-EMAIL-FLAG = 8 THEN
L-EMAIL-STATUS = "DRAFT".
ELSE
IF L-EMAIL:Properties[Aspose.Email.Mapi.MapiPropertyTag:PR_RECEIVED_BY_ENTRYID] = ? THEN
L-EMAIL-STATUS = "SENT".
ELSE
L-EMAIL-STATUS = "RECEIVED".
If there's no attachments to the emails, it works fine since the value of a draft email is always 8 but as soon as you add attachments, it gets all weird with the values so I can't get a range down (I've gotten values like 24 and 242613 while a sent email with an attachment has a value of 49). Anyone know a smarter way of telling if it's a draft or not?
I never had a good experience working with Outlook and Progress internally... what I've managed to accomplish on my project was to create a custom DLL with C# and integrated it on my system.
So, I have an char that triggers some procedures inside my DLL and sends and receives emails (saves as .msg), making my Progress code a lot more easier to manage.
In your case, you should try something like this:
Outlook MailItem: How to distinguish whether mail is incoming or outgoing?
Solution I found was to use a C# DLL to convert the email to an Outlook mail item using the interop:
public bool IsDraft(string path)
{
Outlook.Application oApp = (Outlook.Application)Marshal.GetActiveObject("Outlook.Application");
Outlook.MailItem email = oApp.Session.OpenSharedItem(path) as Outlook.MailItem;
bool isSent = email.Sent;
Marshal.ReleaseComObject(email);
email = null;
return !isSent;
}
I had to release the email object so that code further on wouldn't break.
The PidTagMessageFlags property value is a bitmask of flags. This means a bitwise operator must be applied to check a specific flag value.
IF L-EMAIL-FLAG = 8 THEN
Please replace above line with following line of code. Hope this helps you.
IF (L-EMAIL-FLAG AND 8) = 8 THEN
I work with Aspose as Developer Evangelist.

Retrieve and display last entry indatabase

Frank ยท 2 hours ago
Using Ionic 2, I am unsuccessfully trying to retrieve and display the newGoalWt, newMaxReps, newMinReps, repsToday, and wtToday shown at the bottom of the firebase data image. I do not want to retrieve the other data. I thought I found the answer to this several times, but I haven't. I am not trying to get others to do work I should be doing but I am new to coding and need help at this point. If you have another course that covers this by example please let me know. sample database
I hope this makes sense/is clear.
First thing is to create a provider which gets the details. So in the provider there will be a function like this :
public getRequiredObject(objectKey : String){
return this.database.object('wideGripBPTwo-list/'+ objectKey)
}
Then in the controller/typescript file i would have a variable assigned to the return value of the provider :
this.variableName = this.Provider.getRequiredObject(objectKey);
this.variableName.subscribe(snapshot => {
this.newGoalWt = snapshot.newGoalWt;
this.newMaxReps = snapshot.newMaxReps;
//add other variables here
Lastly in the html file just bind the data :
<ion-label>{{newGoalWt}}</ion-label>
Note I have not added entire provider, .ts file and html file.
Please advise if this makes sense and if you need more assistance.

Linq returning wrong value from DB

I have a super simple select in a wcf service like
BusinessModel.Candidate candidateObject
= dcMUPView.Candidates.SingleOrDefault(dev => dev.Username == username);
But when I hit this code, and then check the candidateObject, it's candidateid value is incorrect. In the DB candidateid is the identity column and primary key. In this case it is 2572884 in the DB but when I look in the candidateObject is says the value returned is something like 0x00274254. Anyone know what might cause something like this?
I think your query is returning the correct record, since 0x00274254 (base 16) = 2572884 (base 10).
If you are checking the value using the debugger, make sure you have the Hexadecimal Display option turned off (see here for more info: Visual Studio debugger - Displaying integer values in Hex).

How to get inserted row ID with WebMatrix

There is a GetLastInsertId method in WebMatrix. However, using Reflector, I can see that it's implemented like this:
[return: Dynamic]
public object GetLastInsertId()
{
return this.QueryValue("SELECT ##Identity", new object[0]);
}
Which, as far as I can see, is a very bad way of doing it, because ##Identity returns the last insert considering every table and every session. I need this restricted to the scope and session I'm working with, so I was expecting this to use SELECT SCOPE_IDENTITY(), since that also seems to be what is most often used according to my reading.
My questions are:
Do the WebMatrix wrappers do something that makes this ok to use in my case?
If not, is there a simple way to get the inserted ID of an insert query using WebMatrix classes, or should I fall back on stuff like SqlClient for this?
I am interested in answers for SQL Server (not compact) if that makes a difference.
I had the same problem, and I read these answers but still couldn't get the code to work correctly. I possibly was misreading the solutions above, but what seemed to work for me was as follows:
var db=Database.Open(...);
var lastInsertID = db.QueryValue("INSERT name into Names; SELECT SCOPE_IDENTITY()");
To quote David Fowler, one of the devs on the Data APIs in WebMatrix: "[SCOPE_IDENITTY] doesn't work on ce". Since we wanted a data API that would work on both CE and regular SQL Server, we used ##Identity. So if you want to use SCOPE_IDENTITY specifically, you should use db.QueryValue method:
var db = Database.Open(...);
db.Insert(...);
var lastInsertId = db.QueryValue("SELECT SCOPE_IDENTITY()")
here is my solution
var db.Database.open('..');
var lastId = db.GetLastInsertId();

Dynamics GP Web Service -- Returning list of sales order based on specific criteria

For a web application, I need to get a list or collection of all SalesOrders that meet the folowing criteria:
Have a WarehouseKey.ID equal to "test", "lucmo" or "Inno"
Have Lines that have a QuantityToBackorder greater than 0
Have Lines that have a RequestedShipDate greater than current day.
I've succesfully used these two methods to retrieve documents, but I can't figure out how return only the ones that meet above criteria.
http://msdn.microsoft.com/en-us/library/cc508527.aspx
http://msdn.microsoft.com/en-us/library/cc508537.aspx
Please help!
Short answer: your query isn't possible through the GP Web Services. Even your warehouse key isn't an accepted criteria for GetSalesOrderList. To do what you want, you'll need to drop to eConnect or direct table access. eConnect has come a long way in .Net if you use the Microsoft.Dynamics.GP.eConnect and Microsoft.Dynamics.GP.eConnect.Serialization libraries (which I highly recommend). Even in eConnect, you're stuck with querying based on the document header rather than line item values, though, so direct table access may be the only way you're going to make it work.
In eConnect, the key piece you'll need is generating a valid RQeConnectOutType. Note the "ForList = 1" part. That's important. Since I've done something similar, here's what it might start out as (you'd need to experiment with the capabilities of the WhereClause, I've never done more than a straightforward equal):
private RQeConnectOutType getRequest(string warehouseId)
{
eConnectOut outDoc = new eConnectOut()
{
DOCTYPE = "Sales_Transaction",
OUTPUTTYPE = 1,
FORLIST = 1,
INDEX1FROM = "A001",
INDEX1TO = "Z001",
WhereClause = string.Format("WarehouseId = '{0}'", warehouseId)
};
RQeConnectOutType outType = new RQeConnectOutType()
{
eConnectOut = outDoc
};
return outType;
}
If you have to drop to direct table access, I recommend going through one of the built-in views. In this case, it looks like ReqSOLineView has the fields you need (LOCNCODE for the warehouseIds, QTYBAOR for backordered quantity, and ReqShipDate for requested ship date). Pull the SOPNUMBE and use them in a call to GetSalesOrderByKey.
And yes, hybrid solutions kinda suck rocks, but I've found you really have to adapt if you're going to use GP Web Services for anything with any complexity to it. Personally, I isolate my libraries by access type and then use libraries specific to whatever process I'm using to coordinate them. So I have Integration.GPWebServices, Integration.eConnect, and Integration.Data libraries that I use practically everywhere and then my individual process libraries coordinate on top of those.

Resources