https://www.youtube.com/watch?v=NVSxc2jg2iY
Wednesday, December 28, 2016
Ax 2012 deki Word-Add in çilesine karşı 2009 Document Handling ile devam
https://www.youtube.com/watch?v=NVSxc2jg2iY
Tuesday, November 15, 2016
Document Attachment through X++
static void hb_attach(Args _args) { DocuRef docuRef; DocuActionArchive archive; CustTable _custtable; str _name; ; _name=@"c:\\hb.docx"; select RecId from _custtable where _custtable.AccountNum =="M0001"; if (_custtable!=null) { ttsBegin; docuRef.clear(); docuRef.RefRecId = _custtable.RecId; docuRef.RefTableId = tableNum("custtable"); docuRef.RefCompanyId = curext(); docuRef.Name = _name; docuRef.TypeId = 'File'; docuRef.insert(); archive = new DocuActionArchive(); archive.add(docuRef, _name); ttsCommit; } }
Get full physical path on attachment AX 2012
select firstOnly DocuRef
order by docuRef.RecId DESC
where
DocuRef.RefRecId == 645484
&& docuRef.RefTableId == 56446
&& docuRef.RefCompanyId == curext();
filename = DocuRef.completeFilename();
Monday, November 14, 2016
Send event by x++
static void Event_sendAlertByCode(Args _args)
{
EventNotificationSource _source;
EventNotification event = EventNotification::construct(EventNotificationSource::Sync);
InventTable inventTable;
;
inventTable = InventTable::find('03.09.2013'); // sample record for which alert is shown
event.parmRecord(inventTable);
event.parmUserId(curuserid()); // user for which this alert to be shown
event.parmDataSourceName('InventTable'); //form datasource
event.parmMenuFunction(new MenuFunction('InventTable', MenuItemtype::Display));
event.parmSubject('Test');
event.parmMessage('Test Event alert');
event.create();
}
{
EventNotificationSource _source;
EventNotification event = EventNotification::construct(EventNotificationSource::Sync);
InventTable inventTable;
;
inventTable = InventTable::find('03.09.2013'); // sample record for which alert is shown
event.parmRecord(inventTable);
event.parmUserId(curuserid()); // user for which this alert to be shown
event.parmDataSourceName('InventTable'); //form datasource
event.parmMenuFunction(new MenuFunction('InventTable', MenuItemtype::Display));
event.parmSubject('Test');
event.parmMessage('Test Event alert');
event.create();
}
Send mail with outlook
Description255 recipientEmail;
Notes emailBody;
Description255 subjectText;
Filename fileName;
SmmOutlookEmail smmOutlookEmail = new SmmOutlookEmail();
recipientEmail = "test@hotmail.com";
subjectText = "Test Email";
fileName = @"C:\Users\admin\Desktop\test.jpg";
emailBody = "Hi,\nThis is a test email";
if (smmOutlookEmail.createMailItem())
{
smmOutlookEmail.addEMailRecipient(recipientEmail);
smmOutlookEmail.addSubject(subjectText);
smmOutlookEmail.addFileAsAttachment(fileName);
smmOutlookEmail.addBodyText(emailBody);
smmOutlookEmail.sendEMail(smmSaveCopyOfEMail::No,true);// false for outlook popup
}
else
{
error("Could not communicate with Microsoft Outlook Client.");
}
Friday, November 11, 2016
progressbar sample
static void operationProgress_progressBars(Args _args)
{
#AviFiles
SysOperationProgress progress = new SysOperationProgress();
int i;
;
progress.setCaption("Progress bar example…");
progress.setAnimation(#AviUpdate);
progress.setTotal(10000);
progress.getCount_RU();
for (i = 1; i <= 10000; i++)
{
progress.setText(strfmt("The value of i is %1", i));
progress.setCount(i, 1);
}
}
{
#AviFiles
SysOperationProgress progress = new SysOperationProgress();
int i;
;
progress.setCaption("Progress bar example…");
progress.setAnimation(#AviUpdate);
progress.setTotal(10000);
progress.getCount_RU();
for (i = 1; i <= 10000; i++)
{
progress.setText(strfmt("The value of i is %1", i));
progress.setCount(i, 1);
}
}
Thursday, November 10, 2016
Kill the excel
System.Collections.IEnumerable processes; System.Collections.IEnumerator enumerator; System.Diagnostics.Process process; try { processes = System.Diagnostics.Process::GetProcessesByName("EXCEL"); enumerator = processes.GetEnumerator(); while (enumerator.MoveNext()) { process = enumerator.get_Current(); process.Kill(); } } catch (Exception::CLRError) { throw error(AifUtil::getClrErrorMessage()); }
thanks for Martin. Martin!!! you are the man:)
https://dynamicsuser.net/ax/f/developers/68865/axapta-close-windows-application-process-with-x
Wednesday, November 9, 2016
Access Denied: MCRInventSearchController
For create products, i will take this error.
Solution:
You'll need to give access to the MCRInventSearch class, updateReleaseProducts method as a ServerMethod on either a privilege, duty, role
Monday, November 7, 2016
Workflow: Create custom work item queue
1) First: CustomXXX document is not available for selection in the work item queue. See below.
To fix this we simply need an attribute on the workflow document class. i.e
[WorkflowDocIsQueueEnabledAttribute(true, "CustomXXX")]
class CustomXXXWorkflowDocument extends WorkflowDocument
{
}
Now we can create a work item queue based on this document.
2) The answer to this was to create the following class:
class CustomXXXTaskCreatedEventHandler extends WorkflowQueueCreatedEventHandler
{
}
protected void mapFields()
{
#Workflow
CustomXXX CustomXXX;
WorkflowDocIsQueueEnabledAttribute attribute;
DictClass dictClass;
dictClass = new DictClass(classNum(CustomXXXDocument));
attribute = dictClass.getAttribute(#WorkflowDocumentAttribute);
CustomXXX = CustomXXX::findRecId(this.parmWorkflowWorkitemTable().RefRecId);
this.parmDocumentId(CustomXXX.CustomXXXId);
this.parmDocumentType(attribute.parmFriendlyName());
this.parmCompanyInfo(CustomXXX.company());
}
HB: This was based on classes\PurchTableTaskCreatedEventHandler.
This class extends WorkflowQueueCreatedEventHandler which in turn implements WorkflowWorkItemsCreatedEventHandler.
In order to trigger this event you must point the workflow tasks to the above class.
Find the task under AOT/Workflow/Tasks. Look for the property WorkItemsCreatedEventHandler. Put the name of your event handler in here. (in my case CustomXXXTaskCreatedEventHandler).
Please go home/Work Items/ Work items assigned to my queues...
thanks David for topic : https://community.dynamics.com/ax/f/33/t/126896
To fix this we simply need an attribute on the workflow document class. i.e
[WorkflowDocIsQueueEnabledAttribute(true, "CustomXXX")]
class CustomXXXWorkflowDocument extends WorkflowDocument
{
}
Now we can create a work item queue based on this document.
2) The answer to this was to create the following class:
class CustomXXXTaskCreatedEventHandler extends WorkflowQueueCreatedEventHandler
{
}
protected void mapFields()
{
#Workflow
CustomXXX CustomXXX;
WorkflowDocIsQueueEnabledAttribute attribute;
DictClass dictClass;
dictClass = new DictClass(classNum(CustomXXXDocument));
attribute = dictClass.getAttribute(#WorkflowDocumentAttribute);
CustomXXX = CustomXXX::findRecId(this.parmWorkflowWorkitemTable().RefRecId);
this.parmDocumentId(CustomXXX.CustomXXXId);
this.parmDocumentType(attribute.parmFriendlyName());
this.parmCompanyInfo(CustomXXX.company());
}
HB: This was based on classes\PurchTableTaskCreatedEventHandler.
This class extends WorkflowQueueCreatedEventHandler which in turn implements WorkflowWorkItemsCreatedEventHandler.
In order to trigger this event you must point the workflow tasks to the above class.
Find the task under AOT/Workflow/Tasks. Look for the property WorkItemsCreatedEventHandler. Put the name of your event handler in here. (in my case CustomXXXTaskCreatedEventHandler).
Please go home/Work Items/ Work items assigned to my queues...
thanks David for topic : https://community.dynamics.com/ax/f/33/t/126896
Workflow: Create custom work item queue
1) First: CustomXXX document is not available for selection in the work item queue. See below.
To fix this we simply need an attribute on the workflow document class. i.e
[WorkflowDocIsQueueEnabledAttribute(true, "CustomXXX")]
class CustomXXXWorkflowDocument extends WorkflowDocument
{
}
Now we can create a work item queue based on this document.
2) The answer to this was to create the following class:
class CustomXXXTaskCreatedEventHandler extends WorkflowQueueCreatedEventHandler
{
}
protected void mapFields()
{
#Workflow
CustomXXX CustomXXX;
WorkflowDocIsQueueEnabledAttribute attribute;
DictClass dictClass;
dictClass = new DictClass(classNum(CustomXXXDocument));
attribute = dictClass.getAttribute(#WorkflowDocumentAttribute);
CustomXXX = CustomXXX::findRecId(this.parmWorkflowWorkitemTable().RefRecId);
this.parmDocumentId(CustomXXX.CustomXXXId);
this.parmDocumentType(attribute.parmFriendlyName());
this.parmCompanyInfo(CustomXXX.company());
}
HB: This was based on classes\PurchTableTaskCreatedEventHandler.
This class extends WorkflowQueueCreatedEventHandler which in turn implements WorkflowWorkItemsCreatedEventHandler.
In order to trigger this event you must point the workflow tasks to the above class.
Find the task under AOT/Workflow/Tasks. Look for the property WorkItemsCreatedEventHandler. Put the name of your event handler in here. (in my case CustomXXXTaskCreatedEventHandler).
Please go home/Work Items/ Work items assigned to my queues...
thanks David for topic : https://community.dynamics.com/ax/f/33/t/126896
To fix this we simply need an attribute on the workflow document class. i.e
[WorkflowDocIsQueueEnabledAttribute(true, "CustomXXX")]
class CustomXXXWorkflowDocument extends WorkflowDocument
{
}
Now we can create a work item queue based on this document.
2) The answer to this was to create the following class:
class CustomXXXTaskCreatedEventHandler extends WorkflowQueueCreatedEventHandler
{
}
protected void mapFields()
{
#Workflow
CustomXXX CustomXXX;
WorkflowDocIsQueueEnabledAttribute attribute;
DictClass dictClass;
dictClass = new DictClass(classNum(CustomXXXDocument));
attribute = dictClass.getAttribute(#WorkflowDocumentAttribute);
CustomXXX = CustomXXX::findRecId(this.parmWorkflowWorkitemTable().RefRecId);
this.parmDocumentId(CustomXXX.CustomXXXId);
this.parmDocumentType(attribute.parmFriendlyName());
this.parmCompanyInfo(CustomXXX.company());
}
HB: This was based on classes\PurchTableTaskCreatedEventHandler.
This class extends WorkflowQueueCreatedEventHandler which in turn implements WorkflowWorkItemsCreatedEventHandler.
In order to trigger this event you must point the workflow tasks to the above class.
Find the task under AOT/Workflow/Tasks. Look for the property WorkItemsCreatedEventHandler. Put the name of your event handler in here. (in my case CustomXXXTaskCreatedEventHandler).
Please go home/Work Items/ Work items assigned to my queues...
thanks David for topic : https://community.dynamics.com/ax/f/33/t/126896
Ax 2012 lookup reference sample
public Common lookupReference(FormReferenceControl _formReferenceControl) { HcmWorker HcmWorker; Query query = new Query(); QueryBuildDataSource queryBuildDataSource; QueryBuildRange queryBuildRange; SysReferenceTableLookup sysTableLookup = SysReferenceTableLookup::newParameters(tableNum(HcmWorker), _formReferenceControl, true); ; sysTableLookup.addLookupField(fieldNum(HcmWorker, PersonnelNumber)); sysTableLookup.addLookupField(fieldNum(HcmWorker, Person)); queryBuildDataSource = query.addDataSource(tableNum(HcmWorker)); return sysTableLookup.performFormLookup(); }
Wednesday, November 2, 2016
Stopped (error): X++ Exception: Work item could not be created. Insufficient rights for user
Stopped (error): X++ Exception: Work item could not be created. Insufficient rights for user xxx.
at SysWorkflowWorkItem-create
SysWorkflowWorkItem-createWorkItems
SysWorkflow-save
SysWorkflowQueue-resume
That workflow is only working if the user john has "System Admin" rights.
For solution;
a developer by going to the AOT > Workflow > Workflow types: select your workflow and in properties in the fields: 'DocumentWebMenuItem' and 'DocumentMenuItem' are menu items that the roles need in order to be able to run your workflows. If you add these, the problem should be solved