Dynamics Ax Web Browser Control

Have you embedded internet explorer on a Ax Form – using ActiveX – an having troubles with pages using  scripting.

It turns out that the embedded control always use IE 7 Mode.

This can be changed to IE11 modes using this x++  – for example in the forms Init method.

 

void sh_set_browser_mode()
{
int handle;
#winapi

 

handle = WinAPI::regOpenKey(#HKEY_CURRENT_USER, ‘Software\\Microsoft\\Internet Explorer\\Main\\FeatureControl\\FEATURE_BROWSER_EMULATION’, #KEY_WRITE);

WinAPI::regSetValueEx(handle,
‘Ax32.Exe’,
#REG_DWORD,
11001 );

WinAPI::regCloseKey(handle);

}

Thanks to: https://weblog.west-wind.com/posts/2011/may/21/web-browser-control-specifying-the-ie-version

 

 

 

Posted in Uncategorized | Leave a comment

Xpath to get body of aif xml message

Private str bodyXpath()
{
return     "/*[local-name()='Envelope' and namespace-uri()='http://schemas.microsoft.com/dynamics/2008/01/documents/Message']/*[local-name()='Body' and " +
"namespace-uri()='http://schemas.microsoft.com/dynamics/2008/01/documents/Message']/*[local-name()='MessageParts' and namespace-uri()='http://schemas.microsoft.com/dynamics/2008/01/documents/Message']/child::*[position()=1]";

}

Posted in Ax | Tagged , , | Leave a comment

Map with value/key pairs to JSON – Ax 2009 – quick

Needed this for a project – would probably choose another implementation in Ax 2012 – need support for arrays.

static str map2JSON(Map _map)
{
str             json;
boolean         first;
str             enumValueString;
MapEnumerator   mapenum;
map             testmap,valuemap;
container       tmpcon;

str enumValue2str(anytype _value, enumId _enumId = 0)
{
DictEnum dictEnum;
;

if (_enumId == 0 && typeof(_value) == Types::Enum)
{
_enumId = DictEnum::value2id(_value);
}
dictEnum = new DictEnum(_enumId);

return  dictEnum.value2Symbol(_value) ;
}

str keyvaluehandling(anytype _value)
{
types _theType;;

_theType = typeof(_value);
switch (_theType)
{
case Types::RString:
case Types::VarString:
case Types::String:     return strfmt(‘”%1″‘,_value);
break;

case Types::Integer:
return int2str(_value);
break;
case Types::Int64:
return int642str(_value);
break ;
case Types::Real:
return num2str(_value,
/* min chars */ 1,
/* decimals */  4,
/* decimals = point */ 1,
/* no thousand sep */ 0);
break;

case Types::Date:
if(_value)
{
return strfmt(‘”%1″‘,date2str(_value, 321,  2, 3, 2, 3, 4));
}
else
{
return ‘”1900-01-01″‘;
}
break;

case Types::Enum:
enumValueString = enumValue2str(_value);
return strfmt(‘”%1″‘,enumValueString);
break;
case Types::Guid:
return strfmt(‘”%1″‘,guid2str(_value));
break ;
case Types::Container:
valuemap = map::create(_value);
if (sysdictclass::isEqualOrSuperclass(classidget(testmap),classidget(valuemap)))
{
return RetailCommonWebAPI::map2JSON(valuemap);
}
case Types::UtcDateTime:
case Types::Record:
case Types::UserType:
case Types::AnyType:
case Types::BLOB:
case Types::void:

default :               throw(error(strfmt(“@SYS73815″,_theType))) ;

}
return ”;
}

str handleKeypair(str keyname, anytype keyvalue)
{
return ( first ? strfmt(‘,”%1″:%2’,keyname,keyvaluehandling(keyvalue)) : strfmt(‘”%1″:%2’,keyname,keyvaluehandling(keyvalue)));
}
;

mapenum = _map.getEnumerator();
while (mapenum.moveNext())
{
json += handleKeypair(mapenum.currentKey(),conpeek(mapenum.currentValue(),1));
first = true;
}

return strfmt(‘{%1}’,json);
}

Test job:

static void soa_test_newPaymentServices(Args _args)
{
abcmodel testenum = ABCModel::Revenue;
Map mymap = new Map(types::String,types::Container);
Map mapinmap = new Map(types::String,types::Container);;

mapinmap.insert(“mapinmap_text”,[“en tekst”]);
mapinmap.insert(“mapinmap_integrer”, [5]);

mymap.insert(“text”,[“en tekst”]);
mymap.insert(“integrer”, [5]);
mymap.insert(“real”,[1.5432]);
mymap.insert(“enum”, [testenum]);
mymap.insert(“date”, [systemdateget()]);
mymap.insert(“map”, [mapinmap.pack()]);
mymap.insert(“date2”, [systemdateget()]);

info(RetailCommonWebAPI::map2JSON(mymap));
}

Posted in Ax | Tagged , | Leave a comment

My blog and twitter

Just remembered I had this blog – not much activity for a long time 🙂
Have I have twitter as well with a bit more activity http://www.twitter.com/sorenandersen

Posted in Uncategorized | Leave a comment

Getting logged out from the Ad periodically?

Try to check out the windows -> Control Panel\All Control Panel Items\Credential Manager
Windows might have stored a login to a server using and outdated password.

Posted in Uncategorized | Leave a comment

Hello world!

Welcome to WordPress.com. This is your first post. Edit or delete it and start blogging!

Posted in Uncategorized | 1 Comment

biztalk 2009 – Exception Caught: The map contains a reference to a schema node that is not valid. Perhaps the schema has changed. Try reloading the map in the BizTalk Mapper. The XSD XPath of the node

  • he BizTalk project contains a BizTalk map. The source schema and the destination schema of the map are referenced from a separate project in the same solution.
  •  You try to validate the map or try to build the BizTalk project.
In this scenario, you may receive an error message that resembles the following:
Exception Caught: The map contains a reference to a schema node that is not valid. Perhaps the schema has changed. Try reloading the map in the BizTalk Mapper. The XSD XPath of the node is: …
My problem was fixed by the "Clean" function in VS

 

Posted in Computere og internet | Leave a comment

Taler om AIF – Outbound with a number of Records per XML

Posted in Uncategorized | Leave a comment

Host a WCF Service in IIS 7 and- Windows_2008 -The_right_way.

Posted in Computere og internet | Leave a comment

Dynamics Ax 2009 recids

Just found this in a comment from "Karel" – but it is very usefull – (but only! for DAX2009)
 
….
Thanks for this tutorial, look into it.

I’ve figured out a fast way to import data in MS Dynamics as well. It uses almost only sql statements:

First let’s create a table (classroom) in dynamics. It has two collumn: RoomNumber and LocationDescription (both String).

Now you want to load 1.500.000 (exact!) classrooms via a CSV file. It has the following sturcture:

A01;Teachers Room
A02;Green Room
C2002;Gymn
….

If you want to add lines in a table without using AX you should fill in the RECIDs properly: AX allows you to reserve X number of recids for a certain table. Use the following code:

static void reserve_classRooms(Args _args)
{
SystemSequence seq;
;
seq = new SystemSequence();
if(seq){
Seq.suspendRecIds(tablenum(classroom));
//In the next commando you reserve 1.500.000 recids. The system will not use these!
print seq.reserveValues(1500000,tablenum(classroom));

// Remove the recId suspension.
Seq.removeRecIdSuspension(tablenum(classroom));
pause;
}
}

The system will print a number to your screen. e.g: 3.000.000.000 Now you know you can use 3.000.000.000 until 3.001.500.000.

Your work in dynamics is now done.
In sql you recreate your table. Only you have to default your Dataareaid and you create an identity on your recid (starting with the value of previous job)

e.g.

create table tmp_classroom (
RoomNumber varchar(20),
LocationDescription varchar (50),
DataAreaId varchar(4) default ‘dat’,
Recid, bigint identity(3000000000,1)
)

Next you create a view on this table. This view represents the format of the csv file (in case extra collumns are not in the csv or the order is different)
e.g.

create view w
as
select roomnumber,locationdescription from classroom

Now you use the bulkinsert commando to load your csv in your view (or in your tmp_Classroom table)
e.g.

bulk insert w from ‘\\networklocation\classrooms.csv’ with (FIELDTERMINATOR = ‘;’)

everything is now correct in your tmp_table (you can do checks on it)

last thing you need to do is copy everything from the tmp_ table in the real table.

insert into classroom(roomnumber,locationdescription,dataareaid, recid) select roomnumber,locationdescription,dataareaid,recid from tmp_classroom

this is it. You can insert 4.500.000lines in less than 2 minutes. Because you’re using powerfull sql server functions

Posted in Computere og internet | Leave a comment