If you want to post a record like this, AX will not let you post, with an error about record is using by another. This code part I learned from Volkan Şişman lets to post:
InventJournalCheckPost journalCheckPost;
JournalForm journalForm;
;
...
journalForm = JournalForm::fromArgs(args);
journalCheckPost = InventJournalCheckPost::newFromForm(args,journalForm);
journalForm.runbaseMainStart();
journalCheckPost.run();
journalForm.runbaseMainEnd(journalCheckPost,false);
20 Temmuz 2015 Pazartesi
15 Temmuz 2015 Çarşamba
AXAPTA - Flexible joins with InventDim Table using InventDimExistsJoin macro
There is a macro to create flexible joins with InventDim table with easy:
InventDimParm dimParm;
InventDim dimValues,dimJoin;
;
...
//Fill fields to use join where condition
dimvalues.wMSLocationId = inventdim.wMSLocationId;
if (inventdim.InventSiteId)
dimvalues.InventSiteId = inventdim.InventSiteId;
if (inventdim.configId)
dimvalues.configId = inventdim.configId;
//Set InventDimParm with fields
dimparm.initFromInventDim(dimValues);
while select lclInventSum
where lclInventSum.ItemId == itemId && leftQty > 0
#InventDimExistsJoin(lclInventSum.InventDimId,dimJoin,dimValues,dimParm)
First parameter was related InventDimId field for join tables, second is InventDim tables local alias, values go with third parameter. The last one is parameter table. There ara different usages of that table.
InventDimParm dimParm;
InventDim dimValues,dimJoin;
;
...
//Fill fields to use join where condition
dimvalues.wMSLocationId = inventdim.wMSLocationId;
if (inventdim.InventSiteId)
dimvalues.InventSiteId = inventdim.InventSiteId;
if (inventdim.configId)
dimvalues.configId = inventdim.configId;
//Set InventDimParm with fields
dimparm.initFromInventDim(dimValues);
while select lclInventSum
where lclInventSum.ItemId == itemId && leftQty > 0
#InventDimExistsJoin(lclInventSum.InventDimId,dimJoin,dimValues,dimParm)
First parameter was related InventDimId field for join tables, second is InventDim tables local alias, values go with third parameter. The last one is parameter table. There ara different usages of that table.
30 Haziran 2015 Salı
Axapta - Show image at grid column
In the sample we will use RefRecId field; show OK image when filled, show Cancel image when empty. For this, we write a display method to the table (or table data source of course):
display ImageRes dispIsOKImg(gzrForeSightOrderLines l)
{
#resAppl;
return l.RefRecId == 0 ? #ImageError : #Image_OK;
}
Add a Window control to grid. At this sample it's name is LineOK. Make AlignControl of control to No. Write display method's name (for this sample is dispIsOKImg) to DataMethod, write table name (gzrForeSightOrderLines for this sample) to Datasource. Write suitable values to Height and Width. I wrote 14 both of them. If your image is so big you make ImageMode value as Size to fit.
You will see pictures periodically refresh when run the form. For prevent this effect, you have to load images at form init:
ClassDeclaration method:
ImageList imageList;
Init method:
#resAppl
imageList = new Imagelist(Imagelist::smalliconWidth(),Imagelist::smalliconHeight());
imagelist.add(new image(#Image_OK));
imagelist.add(new image(#ImageError));
LineOK.imageList(imageList);
change return line like this at the Display method:
return l.RefRecId == 0 ? 1 : 0;
To see/update image list at resAppl macro:
AOT->Macros->ResAppl->Edit
To see all image resources at the system Tools->Development tools-> Embedded resources.
display ImageRes dispIsOKImg(gzrForeSightOrderLines l)
{
#resAppl;
return l.RefRecId == 0 ? #ImageError : #Image_OK;
}
Add a Window control to grid. At this sample it's name is LineOK. Make AlignControl of control to No. Write display method's name (for this sample is dispIsOKImg) to DataMethod, write table name (gzrForeSightOrderLines for this sample) to Datasource. Write suitable values to Height and Width. I wrote 14 both of them. If your image is so big you make ImageMode value as Size to fit.
You will see pictures periodically refresh when run the form. For prevent this effect, you have to load images at form init:
ClassDeclaration method:
ImageList imageList;
Init method:
#resAppl
imageList = new Imagelist(Imagelist::smalliconWidth(),Imagelist::smalliconHeight());
imagelist.add(new image(#Image_OK));
imagelist.add(new image(#ImageError));
LineOK.imageList(imageList);
change return line like this at the Display method:
return l.RefRecId == 0 ? 1 : 0;
To see/update image list at resAppl macro:
AOT->Macros->ResAppl->Edit
To see all image resources at the system Tools->Development tools-> Embedded resources.
10 Şubat 2015 Salı
C# - Create COM compatible DLL and use without app.config file with a web service consume
You can make your DLL as COM compatible a way which I learned from an article:
[ComVisible(true)]
Also Register for COM interop checkbox should be checked from project properties->build page.
You can use Intellisense when using COM object with this:
[ClassInterface(ClassInterfaceType.AutoDual)]
After all you can use DLL yet from your COM compatible language (except there is no binding). When you try to use you get an error; "OLE IDispatch exception code 0 from System.ServiceModel: ServiceModel...". You have to copy app.config file as yourexefile.EXE.app.config or add these red code parts to your class (I got help for this from Paul Mrozowski):
For add this sample web service to your project, you have to right click at Service References than Add Service Reference-> write https://tckimlik.nvi.gov.tr/Service/KPSPublic.asmx to address and push GO.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Runtime.InteropServices;
using System.ServiceModel;
namespace TCKimlik
{
[ComVisible(true)] //for visible COM object
[ClassInterface(ClassInterfaceType.AutoDual)] //for intellisense at using COM
[ProgId("TCKimlik.TCSorgula")] //COM object name
public class TCKimlikClass
{
public bool Dogrula(string adi,string soyadi,Int64 tc,Int32 dogumT)
{
bool ret = false;
//------ for using COM compatible DLL without APP.CONFIG
BasicHttpsBinding binding = new BasicHttpsBinding();
EndpointAddress address = new EndpointAddress("https://tckimlik.nvi.gov.tr/Service/KPSPublic.asmx");
//------ run --------
try
{
Sorgula.KPSPublicSoapClient servis = new Sorgula.KPSPublicSoapClient(binding, address);
ret = servis.TCKimlikNoDogrula(tc, adi, soyadi, dogumT);
}
catch
{
}
return ret;
}
}
}
Now you can use this DLL at COM compatible languages plus .NET. But if you move DLL to client computer without setup you have to register with regasm. I shared project.
There is a sample usage with Microsoft Visual Foxpro:
o=CREATEOBJECT("tckimlik.tcsorgula")
?o.Dogrula("METİN","EMRE",11111111111,1980)
[ComVisible(true)]
Also Register for COM interop checkbox should be checked from project properties->build page.
You can use Intellisense when using COM object with this:
[ClassInterface(ClassInterfaceType.AutoDual)]
After all you can use DLL yet from your COM compatible language (except there is no binding). When you try to use you get an error; "OLE IDispatch exception code 0 from System.ServiceModel: ServiceModel...". You have to copy app.config file as yourexefile.EXE.app.config or add these red code parts to your class (I got help for this from Paul Mrozowski):
For add this sample web service to your project, you have to right click at Service References than Add Service Reference-> write https://tckimlik.nvi.gov.tr/Service/KPSPublic.asmx to address and push GO.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Runtime.InteropServices;
using System.ServiceModel;
namespace TCKimlik
{
[ComVisible(true)] //for visible COM object
[ClassInterface(ClassInterfaceType.AutoDual)] //for intellisense at using COM
[ProgId("TCKimlik.TCSorgula")] //COM object name
public class TCKimlikClass
{
public bool Dogrula(string adi,string soyadi,Int64 tc,Int32 dogumT)
{
bool ret = false;
//------ for using COM compatible DLL without APP.CONFIG
BasicHttpsBinding binding = new BasicHttpsBinding();
EndpointAddress address = new EndpointAddress("https://tckimlik.nvi.gov.tr/Service/KPSPublic.asmx");
//------ run --------
try
{
Sorgula.KPSPublicSoapClient servis = new Sorgula.KPSPublicSoapClient(binding, address);
ret = servis.TCKimlikNoDogrula(tc, adi, soyadi, dogumT);
}
catch
{
}
return ret;
}
}
}
Now you can use this DLL at COM compatible languages plus .NET. But if you move DLL to client computer without setup you have to register with regasm. I shared project.
There is a sample usage with Microsoft Visual Foxpro:
o=CREATEOBJECT("tckimlik.tcsorgula")
?o.Dogrula("METİN","EMRE",11111111111,1980)
Etiketler:
0,
app.config,
C#,
COM DLL,
exception code,
IDispatch,
OLE,
service,
System.ServiceModel,
web,
without
23 Ocak 2015 Cuma
JAVASCRIPT - Solve 403.14 - Forbidden error
I intended learn to Javascript
and got "HTTP Error 403.14 - Forbidden..." error at first try. I found the solution from a blog. Move to "C:\Program Files\IIS Express" (It may different at your computer) folder and run this command:
appcmd set config /section:system.webServer/directoryBrowse /enabled:true
appcmd set config /section:system.webServer/directoryBrowse /enabled:true
Etiketler:
03.14,
403,
aptana,
eclipse,
error,
forbidden,
javascript,
visual studio
2 Ocak 2015 Cuma
SQL SERVER - If noone has Sysadmin rights or SA password is lost?
Go to pproperties of relates servers from SQL Server Configuration Manager. Advanced->Properties than put "-m" parameter. Carefull about you have to put ";" after last parameter and put no space! I mean ";-m" (Without quotes).
Restart to SQL Server. Server will run in single mode.
Run SQLCMD.EXE as administrator. Give Sysadmin rights to your Windows user which you use at login for your SQL Server:
EXEC sp_addsrvrolemember "myserver\myuser","sysadmin";
GO
or
EXEC sp_password NULL, 'newpwd', 'sa';
GO
Don't forget delete parameter and restart server at regular mode!..
Source:
http://blogs.msdn.com/b/raulga/archive/2007/07/12/disaster-recovery-what-to-do-when-the-sa-account-password-is-lost-in-sql-server-2005.aspx
Restart to SQL Server. Server will run in single mode.
Run SQLCMD.EXE as administrator. Give Sysadmin rights to your Windows user which you use at login for your SQL Server:
EXEC sp_addsrvrolemember "myserver\myuser","sysadmin";
GO
or
EXEC sp_password NULL, 'newpwd', 'sa';
GO
Don't forget delete parameter and restart server at regular mode!..
Source:
http://blogs.msdn.com/b/raulga/archive/2007/07/12/disaster-recovery-what-to-do-when-the-sa-account-password-is-lost-in-sql-server-2005.aspx
25 Aralık 2014 Perşembe
AX 2012 - Consume web service with sample turkish citizen ID check
I used a blog when developing this sample. You can download to ready use XPO from there .
1- Create a new Class Library type C# project at Visual Studio.
2- Press right click at project name, select Add service reference and write https://tckimlik.nvi.gov.tr/Service/KPSPublic.asmx?WSDL to Address, write Sorgula to Namespace and press GO so service reference will be shown.
3- Add your project to AOT with Add to AOT .
4- Go to project properties and make
Debug Target = No
Deploy to Client = Yes
Deploy to EP = No
Deploy to Server = Yes
Deploy to SSRS = No
5. Deploy project and down all AX clients. If you don't down all clients at deploy, deploy will fail accoring to blog writer.
This is my sample job:
//Metin Emre, 2.10.2014
static void TCIDTest(Args _args)
{
CLRObject clientType;
TCKimlik.Sorgula.KPSPublicSoapClient cl;
System.Exception ex;
boolean s,erOccured;
System.Exception e;
str ret;
new InteropPermission(InteropKind::ClrInterop).assert();
try
{
clientType = CLRInterop::getType("TCKimlik.Sorgula.KPSPublicSoapClient");
cl = AifUtil::createServiceClient(clientType);
s = cl.TCKimlikNoDogrula(11111111111,"METİN","EMRE",1999);
}
catch(Exception::CLRError)
{
Ex=CLRInterop::getLastException();
ret = Ex.ToString();
if (!strScan(ret,"Not a valid citizen ID",1,strLen(Ret)))
{
info(Ex.ToString());
erOccured = true;
}
}
if (!erOccured)
info(strFmt("%1",s));
}
11111111111 is citizen ID, name and surname after citizen ID and the last born year. If all these are correct, returns true else false.
1- Create a new Class Library type C# project at Visual Studio.
2- Press right click at project name, select Add service reference and write https://tckimlik.nvi.gov.tr/Service/KPSPublic.asmx?WSDL to Address, write Sorgula to Namespace and press GO so service reference will be shown.
3- Add your project to AOT with Add to AOT .
4- Go to project properties and make
Debug Target = No
Deploy to Client = Yes
Deploy to EP = No
Deploy to Server = Yes
Deploy to SSRS = No
5. Deploy project and down all AX clients. If you don't down all clients at deploy, deploy will fail accoring to blog writer.
This is my sample job:
//Metin Emre, 2.10.2014
static void TCIDTest(Args _args)
{
CLRObject clientType;
TCKimlik.Sorgula.KPSPublicSoapClient cl;
System.Exception ex;
boolean s,erOccured;
System.Exception e;
str ret;
new InteropPermission(InteropKind::ClrInterop).assert();
try
{
clientType = CLRInterop::getType("TCKimlik.Sorgula.KPSPublicSoapClient");
cl = AifUtil::createServiceClient(clientType);
s = cl.TCKimlikNoDogrula(11111111111,"METİN","EMRE",1999);
}
catch(Exception::CLRError)
{
Ex=CLRInterop::getLastException();
ret = Ex.ToString();
if (!strScan(ret,"Not a valid citizen ID",1,strLen(Ret)))
{
info(Ex.ToString());
erOccured = true;
}
}
if (!erOccured)
info(strFmt("%1",s));
}
11111111111 is citizen ID, name and surname after citizen ID and the last born year. If all these are correct, returns true else false.
Kaydol:
Kayıtlar (Atom)