from the documentation, M3: v13x Programming in the Web Software Development Kit Training Workbook, I found the example using the M3.IUserService which retrieves the UserContext information, i.e. Company, Division, M3UserId, etc., and this works well.
In my code below there are two types of "test", one is the Local Test (code like it is) and if I reverse the comments it should work with the MIService.
If I use the local test it works, of course, but if I want to use the APIs it doesn't.
Note: The problem I think is the way I inject the MIRecord and MIRequest. Does EXTxxxMI works like the standard APIs of M3?
import { CoreBase, IMIRequest, IMIResponse, IUserContext, MIRecord } from "
@infor-up/m3-odin";
*/
module WebSDK.test1module {
export class test1Ctrl {
static $inject = ["$scope", "m3UserService","MIRecord","MIRequest"];
itemsaved: Array<any> = [];
oitemObj: any = {};
constructor(private scope: ng.IScope, private miService: m3.IMIService) {
console.log("Before getDetails()");
this.getDetails();
console.log("After getDetails()");
}
private getDetails(): void {
/* const icompany: String = "800";
const ifacility: String = "A01";
const istrucType: String = "001";
const inputrecord = new MIRecord();
inputrecord.setString("CONO", icompany);
inputrecord.setString("FACI", ifacility);
inputrecord.setString("STRT", istrucType);
const ipdrnumb: String = "Y10001";
inputrecord.setString("PRNO", ipdrnumb);
*/
// Start code for Local test
const ocompany: String = "ocompany";
const ofacility: String = "ofacility";
const opdrnumb: String = "opdrnumb";
const ostructype: String = "ostructype";
const ofacname: String = "ofacname";
const oitemname: String = "oitemname";
this.oitemObj["CONO"] = ocompany;
this.oitemObj["FACI"] = ofacility;
this.oitemObj["PRNO"] = opdrnumb;
this.oitemObj["STRT"] = ostructype;
this.oitemObj["FACN"] = ofacname;
this.oitemObj["ITDS"] = oitemname;
console.log(this.itemsaved);
this.itemsaved.push(this.oitemObj);
console.log(this.itemsaved);
this.scope["itemsaved"] = this.oitemObj;
// Finish code for Local test
/*
const request: IMIRequest = {
program: "PDS001MI",
transaction: "Get",
record: inputrecord,
outputfields: ["CONO", "FACI", "PRNO", "STRT", "FACN", "ITDS"]
};
this.miService.execute(request).subscribe((response: IMIResponse) => {
if (!response.hasError()) {
// this.logInfo("Customer Basic data for " + customer);
const record: m3.MIRecord = response.item as MIRecord;
this.oitemObj["CONO"] = record["CONO"];
this.oitemObj["FACI"] = record["FACI"];
this.oitemObj["PRNO"] = record["PRNO"];
this.oitemObj["STRT"] = record["STRT"];
this.oitemObj["FACN"] = record["FACN"];
this.oitemObj["ITDS"] = record["ITDS"];
this.logInfo("Company " + this.oitemObj["CONO"]);
console.log(this.itemsaved);
this.itemsaved.push(this.oitemObj);
console.log(this.itemsaved);
this.scope["itemsaved"] = this.oitemObj;
} else {
// this.handleError(response, ipdrnumb);
}
});
*/
}
}
class App extends M3.ApplicationBase {
public onStart() {
this.name = "M3 test1";
this.description = "M3 test1";
this.version = "1.0.0";
this.module = angular.module("test1", ["ui.bootstrap", "odin", "m3"]);
this.module.controller("test1Ctrl", test1Ctrl);
Odin.Log.setDebug();
}
}
new App().start();
}