tag:blogger.com,1999:blog-30994211271157597892024-03-29T08:59:30.077+05:30Dynamics AX2012, AX7, Dynamics 365 Finance and OperationsPrasanhttp://www.blogger.com/profile/12994242712106741793noreply@blogger.comBlogger34125tag:blogger.com,1999:blog-3099421127115759789.post-88722841560586747352020-01-15T16:04:00.000+05:302020-01-15T16:04:06.807+05:30X++ code to Export emails under print management destination settings<div dir="ltr" style="text-align: left;" trbidi="on">
printMgmtSettings printMgmtSettings;<br />
container printerSetting;<br />
SRSPrintDestinationSettings printDestinationSetting;<br />
PrintMgmtDocInstance printMgmtDocInstance;<br />
while select printMgmtSettings<br />
{<br />
printDestinationSetting = new SRSPrintDestinationSettings();<br />
printDestinationSetting.unpack(printMgmtSettings.PrintJobSettings);<br />
<br />
if(printDestinationSetting.printMediumType() == srsPrintMediumType::Email)<br />
{<br />
select * from printMgmtDocInstance where printMgmtDocInstance.RecId==printMgmtSettings.ParentId;<br />
info(strFmt("%1 -%2",printMgmtDocInstance.NodeType, printDestinationSetting.emailTo()));<br />
}<br />
}</div>
Prasanhttp://www.blogger.com/profile/12994242712106741793noreply@blogger.com0tag:blogger.com,1999:blog-3099421127115759789.post-70392228896198792382020-01-15T15:11:00.000+05:302020-01-15T15:11:02.263+05:30X++ code to setup print management destination settings on Customer<div dir="ltr" style="text-align: left;" trbidi="on">
PrintMgmtSettings printMgmtSettings;<br />
PrintMgmtDocInstance printMgmtDocInstance;<br />
CustTable custtable = CustTable::find("C005751");<br />
<br />
container printerSetting;<br />
SRSPrintDestinationSettings printDestinationSetting;<br />
<br />
printMgmtDocInstance = printMgmtDocInstance::find(custtable.RecId,77,printMgmtNodeType::CustTable,printMgmtDocumentType::CustAccountStatement,1);<br />
<br />
if(printMgmtDocInstance.RecId == 0 && custtable.email() != strMin())<br />
{<br />
printerSetting = conNull();<br />
printDestinationSetting = new SRSPrintDestinationSettings();<br />
<br />
ttsBegin;<br />
<br />
printMgmtDocInstance.DocumentType = printMgmtDocumentType::CustAccountStatement;<br />
//printMgmtDocInstance.Name = strFmt("Email 'Account Statements' to %1", custtable.AccountNum);<br />
printMgmtDocInstance.NodeType = printMgmtNodeType::CustTable;<br />
printMgmtDocInstance.PrintType = PrintMgmtDocInstancetype::Original;<br />
printMgmtDocInstance.PriorityId = 1;<br />
printMgmtDocInstance.ReferencedRecId = custtable.recId;<br />
printMgmtDocInstance.ReferencedTableId = 77;// CustTable;<br />
printMgmtDocInstance.insert();<br />
<br />
// just use a new instance of SRSPrintDestinationSettings to serialize an empty container<br />
printDestinationSetting.unpack(printerSetting);<br />
printDestinationSetting.printMediumType(srsPrintMediumType::Email);<br />
printDestinationSetting.emailTo(custtable.email());<br />
//printDestinationSetting.emailCc(ccEmailString);<br />
printDestinationSetting.emailSubject("Proserv statements");<br />
printDestinationSetting.emailAttachmentFileFormat(SRSReportFileFormat::PDF);<br />
printerSetting = printDestinationSetting.pack();<br />
<br />
<br />
printMgmtSettings.clear();<br />
printMgmtSettings.Description = printmgmtdocInstance.Name;<br />
printMgmtSettings.NumberOfCopies = 1;<br />
printMgmtSettings.ParentId = printmgmtdocInstance.RecId;<br />
printMgmtSettings.PrintJobSettings = printerSetting;<br />
printMgmtSettings.PriorityId = printMgmtDocInstance.PriorityId;<br />
printMgmtSettings.insert();<br />
<br />
ttsCommit;<br />
}</div>
Prasanhttp://www.blogger.com/profile/12994242712106741793noreply@blogger.com0tag:blogger.com,1999:blog-3099421127115759789.post-65371266615522648682020-01-15T15:01:00.001+05:302020-01-15T15:01:40.712+05:30X++ code to create/update party contact details- Customer/vendor/Employee/Prospect<div dir="ltr" style="text-align: left;" trbidi="on">
below code to update customer/Vendor contact details like email, telephone, fax, etc.,<br />
<br />
CustTable custTable;<br />
<br />
void setUpContacts(Addressing _desc, RefRecId _party,LogisticsElectronicAddressMethodType _type,LogisticsElectronicAddressLocator _value )<br />
{<br />
DirPartyLocation dirPartyLocation,dirPartyLocationNew;<br />
LogisticsLocation logisticsLocation;<br />
LogisticsElectronicAddress logEleAddress;<br />
<br />
select forupdate forUpdate dirPartyLocation where dirPartyLocation.Party == _party<br />
join logisticsLocation where logisticsLocation.Description == _desc<br />
&& logisticsLocation.recid==dirPartyLocation.Location<br />
join forUpdate logEleAddress where logEleAddress.Location == logisticsLocation.recid<br />
&& logEleAddress.Type == _type;<br />
if(logEleAddress.RecId != 0 && logEleAddress.Locator != _value)<br />
{<br />
ttsBegin;<br />
logEleAddress.validTimeStateUpdateMode(ValidTimeStateUpdate::Correction);<br />
logEleAddress.Locator = _value;<br />
logEleAddress.update();<br />
ttsCommit;<br />
}<br />
else if(logEleAddress.RecId == 0)<br />
{<br />
logisticsLocation = LogisticsLocation::create(_desc);<br />
dirPartyLocationNew.Party = _party;<br />
dirPartyLocationNew.Location = logisticsLocation.RecId;<br />
dirPartyLocationNew.ValidFrom = DateTimeUtil::utcNow();<br />
dirPartyLocationNew.ValidTo = DateTimeUtil::maxValue();<br />
dirPartyLocationNew.insert();<br />
<br />
logEleAddress.Location = logisticsLocation.RecId;<br />
logEleAddress.Type = _type;<br />
logEleAddress.Locator = _value;<br />
logEleAddress.insert();<br />
}<br />
}<br />
custTable = CustTable::find("C004800");<br />
setUpContacts("Email",custTable.Party,LogisticsElectronicAddressMethodType::Email,"prasan@domain.com");<br />
//Contact Name/description, Party, contact type, Email address</div>
Prasanhttp://www.blogger.com/profile/12994242712106741793noreply@blogger.com0tag:blogger.com,1999:blog-3099421127115759789.post-52182497219034896862019-11-12T14:23:00.002+05:302019-11-12T14:23:54.588+05:30New Microsoft certifications for Dynamics 365 - role based<div dir="ltr" style="text-align: left;" trbidi="on">
HI,<br />
<br />
Microsoft has released its updated certifications on all Microsoft stack.<br />
<br />
you can also filter the technology based on Dynamics 365 for certifications Dynamics 365 Finance and operations. Most of the AX previous certifications will expire this year end and until june next year, but the transcript will be available if you have completed any before they expire.<br />
<br />
<a href="https://www.microsoft.com/en-us/learning/browse-all-certifications.aspx">https://www.microsoft.com/en-us/learning/browse-all-certifications.aspx</a><br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhJGOAjPUWw8KwyWo3jfz4v1TbAyPcOCaMToz3q2u4Qzk-O2joD88aq_wqpEDojv2PDLW5n96UIqTOAr_Kz2qXbK8_P4bmc4G2CJEiQmwpKcCti3XEG4TgCqQwzoWxTEpOCHvgKj72eWTM/s1600/MSC.JPG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="883" data-original-width="1357" height="412" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhJGOAjPUWw8KwyWo3jfz4v1TbAyPcOCaMToz3q2u4Qzk-O2joD88aq_wqpEDojv2PDLW5n96UIqTOAr_Kz2qXbK8_P4bmc4G2CJEiQmwpKcCti3XEG4TgCqQwzoWxTEpOCHvgKj72eWTM/s640/MSC.JPG" width="640" /></a></div>
<br />
<br />
Good luck.<br />
Thanks<br />
Prasan</div>
Prasanhttp://www.blogger.com/profile/12994242712106741793noreply@blogger.com0tag:blogger.com,1999:blog-3099421127115759789.post-91055320980811599772019-11-12T14:11:00.000+05:302019-11-12T14:15:03.758+05:30List of free AX7/D365 courses available for download<div dir="ltr" style="text-align: left;" trbidi="on">
Hi,<br />
<br />
Below are the list of AX7 and D365 finance and operations courses available for free downloaded.<br />
<br />
<a href="https://community.dynamics.com/365/b/learningcurriculum/posts/list-of-courses-available-for-download">https://community.dynamics.com/365/b/learningcurriculum/posts/list-of-courses-available-for-download</a><br />
<br />
and additional R3 courses available in below link<br />
<a href="https://community.dynamics.com/365/b/learningcurriculum/posts/we-ve-added-more-ax-2012-r3-courses-for-download">https://community.dynamics.com/365/b/learningcurriculum/posts/we-ve-added-more-ax-2012-r3-courses-for-download</a><br />
<br />
<br />
also about how to download and run this course information will be available in the below link.<br />
<br />
<a href="https://community.dynamics.com/365/b/learningcurriculum/posts/how-to-run-a-downloaded-course">https://community.dynamics.com/365/b/learningcurriculum/posts/how-to-run-a-downloaded-course</a><br />
<br />
PS: All information are provided from Microsoft websites.<br />
<br />
Happy AX/D365 learning and good luck,<br />
<br />
Thanks,<br />
Prasan</div>
Prasanhttp://www.blogger.com/profile/12994242712106741793noreply@blogger.com0tag:blogger.com,1999:blog-3099421127115759789.post-20183918714963517962019-11-12T13:43:00.001+05:302019-11-12T13:43:55.696+05:30AX Pending workflows using X++<div dir="ltr" style="text-align: left;" trbidi="on">
Below is the X++ code to get the active pending workflows which are waiting for approvals and yet to approve.<br />
<br />
workflowTrackingStatusTable is the header table which holds information about the order and the order which triggered the workflow and the current status of the workflow approvals.<br />
<br />
workflowworkitemTable is the table which holds the information about who are all users are required to action the workflow for the particular workflow instance, once the approvee actioned then record will be deleted from this table and new approver is added to this table with new record.<br />
<br />
workflowtrackingcommenttable will holds the comments of the user who has submitted, approved,rejected.<br />
<br />
while select /*firstOnly10*/ workflowTrackingStatusTable //order by workflowworkitemTable.createdDateTime asc<br />
where workflowTrackingStatusTable.TrackingStatus == WorkflowTrackingStatus::Pending<br />
//&& workflowTrackingStatusTable.InstanceNumber=='INS2367227'<br />
//TODO: for testing- commet it in LIVE<br />
&& (workflowTrackingStatusTable.ContextTableId == 1425//Supplier Invoice<br />
|| workflowTrackingStatusTable.ContextTableId == 1967//Sales quotations<br />
|| workflowTrackingStatusTable.ContextTableId == 345//Purchase order<br />
|| workflowTrackingStatusTable.ContextTableId == 1551//Purchase requisitions<br />
|| workflowTrackingStatusTable.ContextTableId == 617//Invoice proposals<br />
|| workflowTrackingStatusTable.ContextTableId == 484//Travel expense claims<br />
|| workflowTrackingStatusTable.ContextTableId == 4627) //Timesheet<br />
&& workflowTrackingStatusTable.ContextCompanyId != "01"<br />
&& (((workflowTrackingStatusTable.ContextTableId != 1551 && workflowTrackingStatusTable.ContextTableId != 484) && workflowTrackingStatusTable.ContextCompanyId != strMin())<br />
|| (workflowTrackingStatusTable.ContextTableId == 1551 || workflowTrackingStatusTable.ContextTableId == 484))<br />
&& workflowTrackingStatusTable.ContextRecId != 0<br />
&& workflowTrackingStatusTable.ContextTableId != 0<br />
join workflowworkitemTable<br />
where workflowTrackingStatusTable.CorrelationId==workflowworkitemTable.CorrelationId<br />
&& workflowworkitemTable.Status==WorkflowWorkItemStatus::Pending<br />
//&& workflowworkitemTable.UserId == 'prasan.k'<br />
&& workflowworkitemTable.modifiedDateTime >= dateStart<br />
//TODO:Uncomment the date criteia when release to LIVE<br />
outer Join workflowtrackingtable<br />
where workflowtrackingtable.Workflowtrackingstatustable==workflowTrackingStatusTable.recId<br />
&& workflowtrackingtable.TrackingType == WorkflowTrackingType::Submission<br />
&& workflowtrackingtable.User == workflowworkitemTable.UserId<br />
outer join workflowtrackingcommenttable<br />
where workflowtrackingcommenttable.trackingid ==workflowtrackingtable.trackingId<br />
{<br />
<br />
}</div>
Prasanhttp://www.blogger.com/profile/12994242712106741793noreply@blogger.com0tag:blogger.com,1999:blog-3099421127115759789.post-57640707617321820162019-11-12T13:36:00.000+05:302019-11-12T13:36:39.932+05:30Workflow Approvals message tracking X++<div dir="ltr" style="text-align: left;" trbidi="on">
Helps to find the approvals tracking like who and all are approved so far for the particular workflow and what are the workflow approval comments as such in X++ code.<br />
<br />
<br />
<br />
<br />
private str getworkflowTrackmessage(WorkflowInstanceNumber _instanceNumber)<br />
{<br />
WORKFLOWTRACKINGSTATUSTABLE w;<br />
WORKFLOWTRACKINGTABLE wt ;<br />
WORKFLOWTRACKINGTABLE wt2;<br />
workflowsteptable wst;<br />
workflowElementtable wet;<br />
workflowTrackingWorkItem wtw;<br />
UserInfo user;<br />
UserInfo user2;<br />
str txt,ret;<br />
workflowtrackingcommenttable wtct;<br />
boolean first=true;<br />
<br />
while select * from w ORDER BY wt2.CREATEDdATEtIME ASC<br />
where w.instANCEnUMBER==_instanceNumber//'INS2380404'//INS2383500'//<br />
join wt2 where w.recId == wt2.workflowTrackingStatusTable && wt2.USER!='axwfexec'<br />
join wtct where wt2.RecId==wtct.WorkflowTrackingTable<br />
outer join wtw where wt2.recId==wtw.workflowTrackingTable<br />
outer join wst where wst.stepId == wt2.stepId<br />
// join wet where wet.ElementId == wt2.ElementId<br />
outer join user where user.id == wt2.User<br />
outer join user2 where user2.id==wtw.ToUser<br />
{<br />
txt ='';<br />
if (wt2.TrackingType == WorkflowTrackingType::Approval)<br />
{<br />
txt = strFmt("%1 : %2 Approved on %3 ", wst.Name, User.name,wt2.createdDateTime);<br />
if (wtct.Comment != strMin())<br />
{<br />
txt = strFmt("%1 ,Comments: %2",txt, wtct.Comment);<br />
}<br />
//info(txt);<br />
}<br />
<br />
if (wt2.TrackingType == WorkflowTrackingType::Delegation)<br />
{<br />
txt =strFmt("%1 : %2 Delegated to %3 on %4",wst.Name,User.name,user2.name,wt2.createdDateTime);<br />
if (wtct.Comment != strMin())<br />
{<br />
txt = strFmt("%1 ,Comments: %2",txt, wtct.Comment);<br />
}<br />
//info(txt);<br />
}<br />
<br />
if (wt2.TrackingType == WorkflowTrackingType::Rejection)<br />
{<br />
txt = strFmt("%1 : %2 Rejected on %3",wst.Name, User.name,wt2.createdDateTime);<br />
if (wtct.Comment != strMin())<br />
{<br />
txt = strFmt("%1 ,Comments: %2",txt, wtct.Comment);<br />
}<br />
//info(txt);<br />
}<br />
<br />
if (wt2.TrackingType == WorkflowTrackingType::Creation)<br />
{<br />
txt =strFmt("%1 : Assigned to user: %2 on %3",wst.Name, User.name,wt2.createdDateTime);<br />
if (wtct.Comment != strMin())<br />
{<br />
txt = strFmt("%1 ,Comments: %2",txt, wtct.Comment);<br />
}<br />
//info(txt);<br />
}<br />
<br />
if (wt2.TrackingType == WorkflowTrackingType::Submission)<br />
{<br />
txt = strFmt("Submitted by : %1 on %2", User.name,wt2.createdDateTime);<br />
if (wtct.Comment != strMin())<br />
{<br />
txt = strFmt("%1 ,Comments: %2", txt, wtct.Comment);<br />
}<br />
//info(txt);<br />
}<br />
if(first)<br />
{<br />
ret = txt;<br />
first = false;<br />
}<br />
else<br />
{<br />
ret = ret + '\n' + txt;<br />
}<br />
}<br />
return ret;<br />
}</div>
Prasanhttp://www.blogger.com/profile/12994242712106741793noreply@blogger.com0tag:blogger.com,1999:blog-3099421127115759789.post-78161877861847438052019-10-30T13:16:00.002+05:302019-10-30T13:16:41.612+05:30MultiSelectHelper class - Select multilpe records in form grid to update the data altogether once.<div dir="ltr" style="text-align: left;" trbidi="on">
1) Create a class that extends the runbase class.<br />
<br />
2) write a main method to handle the class methods and its arugments<br />
<br />
In main method declare the below helper class<br />
<b> MultiSelectionHelper helper;//multiselect</b><br />
<br />
and also validate the class is invoked based on correct paramaters and caller<br />
<br />
for example: if(_args && _args.dataset() == tableNum(VendInvoiceInfoTable))//if class is invoked from table VendInvoiceInfoTable.<br />
<br />
also initialize the helper class as below<br />
<b>helper = MultiSelectionHelper::createFromCaller(_args.caller());</b><br />
<br />
read the first record as vendInvoiceInfoTable = <b>helper.getFirst();</b><br />
<br />
and next records as vendInvoiceInfoTable = <b>helper.getNext();</b><br />
<br />
loop the multiple records recading<br />
while (vendInvoiceInfoTable)<br />
{<br />
info(vendInvoiceInfoTable.num);<br />
<br />
vendInvoiceInfoTable = helper.getNext();<br />
<br />
}<br />
<br />
refresh the caller form - formDataSourceRefresh(VendInvoiceInfoTable); this will help to show the data updated inmmidiately after the function runs.<br />
<br />
Invoke this class using Action menu item and please make sure to setup the <b>menu property :MultiSelect to YES </b>whereever you add this menuitem on the form<br />
<br />
<br />
<br />
complete example:<br />
<br />
MultiSelectionHelper helper;//multiselect<br />
if(_args && _args.dataset() == tableNum(VendInvoiceInfoTable))<br />
{<br />
<br />
helper = MultiSelectionHelper::createFromCaller(_args.caller());<br />
vendInvoiceInfoTable = helper.getFirst();<br />
<br />
if (pendingInvoiceUpdate.prompt())<br />
{<br />
while (vendInvoiceInfoTable)<br />
{<br />
if(vendInvoiceInfoTable ))<br />
{<br />
info(vendInvoiceInfoTable.num);<br />
}<br />
vendInvoiceInfoTable = helper.getNext();<br />
}<br />
formDataSourceRefresh(VendInvoiceInfoTable);//refresh the caller form<br />
}<br />
}</div>
Prasanhttp://www.blogger.com/profile/12994242712106741793noreply@blogger.com0tag:blogger.com,1999:blog-3099421127115759789.post-65887643587161233092019-03-20T16:17:00.000+05:302019-03-20T18:59:00.398+05:30Consuming AIF web services deployed from Dynamics Ax from External client- Mobile app<div dir="ltr" style="text-align: left;" trbidi="on">
Hi folks,<br />
<br />
Hope you are well!!<br />
<br />
<br />
I have found some interesting things on how to communicate to AX from external client using AIF Websrvice<br />
<br />
Once after the service classes is created in AX and deployed under Inbound ports- the svc file exposes the client.<br />
<br />
we need to refer this web service reference using C#.<br />
<br />
IN VS we need to use 'Add referencne' option and specify the svc file path where it path can be found on AX inbound port.<br />
<br />
<br />
For example the path looks like this.<br />
http://SERVERNane/MicrosoftDynamicsAXAif60/Messenger/xppservice.svc<br />
where Messanger in the path is the name of the service.<br />
<br />
once the service reference is created we need to use and refer that in C# code<br />
<br />
using MessangerSolution.MessangerApp;<br />
=>Name of the service refrence created in C# is MessangerApp<br />
<br />
declare the service<br />
MessangerApp.BasicHttpBinding_PSV_Messenger <b>app </b>= new BasicHttpBinding_PSV_Messenger();<br />
<br />
Providing credentials:<br />
app.UseDefaultCredentials = FALSE;<br />
app.Credentials = new System.Net.NetworkCredential("USERVNAME","SECURE PASSWORD","DOMAIN");<br />
<br />
then you can invoke the service class methods like<br />
app.PassMessage();<br />
<br />
This also fixes the below issue on network credentials:<br />
System.Net.WebException: The request failed with HTTP status 401: Unauthorized</div>
Prasanhttp://www.blogger.com/profile/12994242712106741793noreply@blogger.com0tag:blogger.com,1999:blog-3099421127115759789.post-30696532434222651522017-12-27T13:04:00.002+05:302017-12-27T13:04:51.573+05:30Database Re-Index script<div dir="ltr" style="text-align: left;" trbidi="on">
<span style="color: blue; font-size: x-small;"><span style="color: blue; font-size: x-small;">Hi, Below is the script to re-build the database indesxes- to imporove performance of the system. hope this helps</span></span><br />
<span style="color: blue; font-size: x-small;"><span style="color: blue; font-size: x-small;"><br /></span></span><br />
<span style="color: blue; font-size: x-small;"><span style="color: blue; font-size: x-small;"><br /></span></span><br />
<span style="color: blue; font-size: x-small;"><span style="color: blue; font-size: x-small;">SET</span></span><span style="font-size: x-small;"> </span><span style="color: blue; font-size: x-small;"><span style="color: blue; font-size: x-small;">nocount</span></span><span style="font-size: x-small;"> </span><span style="color: blue; font-size: x-small;"><span style="color: blue; font-size: x-small;">ON</span></span><span style="color: grey; font-size: x-small;"><span style="color: grey; font-size: x-small;">;</span></span><span style="font-size: x-small;"> </span><br />
<span style="font-size: x-small;">
</span><span style="color: blue; font-size: x-small;"><span style="color: blue; font-size: x-small;"></span></span><br />
<span style="color: blue; font-size: x-small;"><span style="color: blue; font-size: x-small;">DECLARE</span></span><span style="font-size: x-small;"> @objectid </span><span style="color: blue; font-size: x-small;"><span style="color: blue; font-size: x-small;">INT</span></span><span style="color: grey; font-size: x-small;"><span style="color: grey; font-size: x-small;">;</span></span><span style="font-size: x-small;"> </span><br />
<span style="font-size: x-small;">
</span><span style="color: blue; font-size: x-small;"><span style="color: blue; font-size: x-small;"></span></span><br />
<span style="color: blue; font-size: x-small;"><span style="color: blue; font-size: x-small;">DECLARE</span></span><span style="font-size: x-small;"> @indexid </span><span style="color: blue; font-size: x-small;"><span style="color: blue; font-size: x-small;">INT</span></span><span style="color: grey; font-size: x-small;"><span style="color: grey; font-size: x-small;">;</span></span><span style="font-size: x-small;"> </span><br />
<span style="font-size: x-small;">
</span><span style="color: blue; font-size: x-small;"><span style="color: blue; font-size: x-small;"></span></span><br />
<span style="color: blue; font-size: x-small;"><span style="color: blue; font-size: x-small;">DECLARE</span></span><span style="font-size: x-small;"> @partitioncount </span><span style="color: blue; font-size: x-small;"><span style="color: blue; font-size: x-small;">BIGINT</span></span><span style="color: grey; font-size: x-small;"><span style="color: grey; font-size: x-small;">;</span></span><span style="font-size: x-small;"> </span><br />
<span style="font-size: x-small;">
</span><span style="color: blue; font-size: x-small;"><span style="color: blue; font-size: x-small;"></span></span><br />
<span style="color: blue; font-size: x-small;"><span style="color: blue; font-size: x-small;">DECLARE</span></span><span style="font-size: x-small;"> @schemaname </span><span style="color: blue; font-size: x-small;"><span style="color: blue; font-size: x-small;">NVARCHAR</span></span><span style="color: grey; font-size: x-small;"><span style="color: grey; font-size: x-small;">(</span></span><span style="font-size: x-small;">130</span><span style="color: grey; font-size: x-small;"><span style="color: grey; font-size: x-small;">);</span></span><span style="font-size: x-small;"> </span><br />
<span style="font-size: x-small;">
</span><span style="color: blue; font-size: x-small;"><span style="color: blue; font-size: x-small;"></span></span><br />
<span style="color: blue; font-size: x-small;"><span style="color: blue; font-size: x-small;">DECLARE</span></span><span style="font-size: x-small;"> @objectname </span><span style="color: blue; font-size: x-small;"><span style="color: blue; font-size: x-small;">NVARCHAR</span></span><span style="color: grey; font-size: x-small;"><span style="color: grey; font-size: x-small;">(</span></span><span style="font-size: x-small;">130</span><span style="color: grey; font-size: x-small;"><span style="color: grey; font-size: x-small;">);</span></span><span style="font-size: x-small;"> </span><br />
<span style="font-size: x-small;">
</span><span style="color: blue; font-size: x-small;"><span style="color: blue; font-size: x-small;"></span></span><br />
<span style="color: blue; font-size: x-small;"><span style="color: blue; font-size: x-small;">DECLARE</span></span><span style="font-size: x-small;"> @indexname </span><span style="color: blue; font-size: x-small;"><span style="color: blue; font-size: x-small;">NVARCHAR</span></span><span style="color: grey; font-size: x-small;"><span style="color: grey; font-size: x-small;">(</span></span><span style="font-size: x-small;">130</span><span style="color: grey; font-size: x-small;"><span style="color: grey; font-size: x-small;">);</span></span><span style="font-size: x-small;"> </span><br />
<span style="font-size: x-small;">
</span><span style="color: blue; font-size: x-small;"><span style="color: blue; font-size: x-small;"></span></span><br />
<span style="color: blue; font-size: x-small;"><span style="color: blue; font-size: x-small;">DECLARE</span></span><span style="font-size: x-small;"> @partitionnum </span><span style="color: blue; font-size: x-small;"><span style="color: blue; font-size: x-small;">BIGINT</span></span><span style="color: grey; font-size: x-small;"><span style="color: grey; font-size: x-small;">;</span></span><span style="font-size: x-small;"> </span><br />
<span style="font-size: x-small;">
</span><span style="color: blue; font-size: x-small;"><span style="color: blue; font-size: x-small;"></span></span><br />
<span style="color: blue; font-size: x-small;"><span style="color: blue; font-size: x-small;">DECLARE</span></span><span style="font-size: x-small;"> @partitions </span><span style="color: blue; font-size: x-small;"><span style="color: blue; font-size: x-small;">BIGINT</span></span><span style="color: grey; font-size: x-small;"><span style="color: grey; font-size: x-small;">;</span></span><span style="font-size: x-small;"> </span><br />
<span style="font-size: x-small;">
</span><span style="color: blue; font-size: x-small;"><span style="color: blue; font-size: x-small;"></span></span><br />
<span style="color: blue; font-size: x-small;"><span style="color: blue; font-size: x-small;">DECLARE</span></span><span style="font-size: x-small;"> @frag </span><span style="color: blue; font-size: x-small;"><span style="color: blue; font-size: x-small;">FLOAT</span></span><span style="color: grey; font-size: x-small;"><span style="color: grey; font-size: x-small;">;</span></span><span style="font-size: x-small;"> </span><br />
<span style="font-size: x-small;">
</span><span style="color: blue; font-size: x-small;"><span style="color: blue; font-size: x-small;"></span></span><br />
<span style="color: blue; font-size: x-small;"><span style="color: blue; font-size: x-small;">DECLARE</span></span><span style="font-size: x-small;"> @command </span><span style="color: blue; font-size: x-small;"><span style="color: blue; font-size: x-small;">NVARCHAR</span></span><span style="color: grey; font-size: x-small;"><span style="color: grey; font-size: x-small;">(</span></span><span style="font-size: x-small;">4000</span><span style="color: grey; font-size: x-small;"><span style="color: grey; font-size: x-small;">);</span></span><span style="font-size: x-small;"> </span><br />
<span style="font-size: x-small;">
</span><br />
<span style="color: green; font-size: x-small;"><br />
<span style="color: green; font-size: x-small;"><br />
-- Conditionally select tables and indexes from the sys.dm_db_index_physical_stats function <br />
<br />
-- and convert object and index IDs to names. <br />
</span><br /></span><span style="color: blue; font-size: x-small;"><span style="color: blue; font-size: x-small;"></span></span><span style="color: blue; font-size: x-small;"><span style="color: blue; font-size: x-small;">SELECT</span></span><span style="font-size: x-small;"> </span><span style="color: magenta; font-size: x-small;"><span style="color: magenta; font-size: x-small;">OBJECT_ID</span></span><span style="font-size: x-small;"> </span><span style="color: blue; font-size: x-small;"><span style="color: blue; font-size: x-small;">AS</span></span><span style="font-size: x-small;"> objectid</span><span style="color: grey; font-size: x-small;"><span style="color: grey; font-size: x-small;">,</span></span><span style="font-size: x-small;"> </span><br />
<span style="font-size: x-small;">
</span><br />
<span style="font-size: x-small;"> INDEX_ID </span><span style="color: blue; font-size: x-small;"><span style="color: blue; font-size: x-small;">AS</span></span><span style="font-size: x-small;"> indexid</span><span style="color: grey; font-size: x-small;"><span style="color: grey; font-size: x-small;">,</span></span><span style="font-size: x-small;"> </span><br />
<span style="font-size: x-small;">
</span><br />
<span style="font-size: x-small;"> PARTITION_NUMBER </span><span style="color: blue; font-size: x-small;"><span style="color: blue; font-size: x-small;">AS</span></span><span style="font-size: x-small;"> partitionnum</span><span style="color: grey; font-size: x-small;"><span style="color: grey; font-size: x-small;">,</span></span><span style="font-size: x-small;"> </span><br />
<span style="font-size: x-small;">
</span><br />
<span style="font-size: x-small;"> AVG_FRAGMENTATION_IN_PERCENT </span><span style="color: blue; font-size: x-small;"><span style="color: blue; font-size: x-small;">AS</span></span><span style="font-size: x-small;"> frag </span><br />
<span style="font-size: x-small;">
</span><span style="color: blue; font-size: x-small;"><span style="color: blue; font-size: x-small;"></span></span><br />
<span style="color: blue; font-size: x-small;"><span style="color: blue; font-size: x-small;">INTO</span></span><span style="font-size: x-small;"> #work_to_do </span><br />
<span style="font-size: x-small;">
</span><span style="color: blue; font-size: x-small;"><span style="color: blue; font-size: x-small;"></span></span><br />
<span style="color: blue; font-size: x-small;"><span style="color: blue; font-size: x-small;">FROM</span></span><span style="font-size: x-small;"> </span><span style="color: green; font-size: x-small;"><span style="color: green; font-size: x-small;">sys</span></span><span style="color: grey; font-size: x-small;"><span style="color: grey; font-size: x-small;">.</span></span><span style="color: green; font-size: x-small;"><span style="color: green; font-size: x-small;">DM_DB_INDEX_PHYSICAL_STATS</span></span><span style="color: blue; font-size: x-small;"><span style="color: blue; font-size: x-small;"> </span></span><span style="color: grey; font-size: x-small;"><span style="color: grey; font-size: x-small;">(</span></span><span style="color: magenta; font-size: x-small;"><span style="color: magenta; font-size: x-small;">DB_ID</span></span><span style="color: grey; font-size: x-small;"><span style="color: grey; font-size: x-small;">(),</span></span><span style="font-size: x-small;"> </span><span style="color: grey; font-size: x-small;"><span style="color: grey; font-size: x-small;">NULL,</span></span><span style="font-size: x-small;"> </span><span style="color: grey; font-size: x-small;"><span style="color: grey; font-size: x-small;">NULL,</span></span><span style="font-size: x-small;"> </span><span style="color: grey; font-size: x-small;"><span style="color: grey; font-size: x-small;">NULL,</span></span><span style="font-size: x-small;"> </span><span style="color: red; font-size: x-small;"><span style="color: red; font-size: x-small;">'LIMITED'</span></span><span style="color: grey; font-size: x-small;"><span style="color: grey; font-size: x-small;">)</span></span><span style="font-size: x-small;"> </span><br />
<span style="font-size: x-small;">
</span><span style="color: blue; font-size: x-small;"><span style="color: blue; font-size: x-small;"></span></span><br />
<span style="color: blue; font-size: x-small;"><span style="color: blue; font-size: x-small;">WHERE</span></span><span style="font-size: x-small;"> AVG_FRAGMENTATION_IN_PERCENT </span><span style="color: grey; font-size: x-small;"><span style="color: grey; font-size: x-small;">></span></span><span style="font-size: x-small;"> 10.0 </span><br />
<span style="font-size: x-small;">
</span><br />
<span style="font-size: x-small;"> </span><span style="color: grey; font-size: x-small;"><span style="color: grey; font-size: x-small;">AND</span></span><span style="font-size: x-small;"> INDEX_ID </span><span style="color: grey; font-size: x-small;"><span style="color: grey; font-size: x-small;">></span></span><span style="font-size: x-small;"> 0</span><span style="color: grey; font-size: x-small;"><span style="color: grey; font-size: x-small;">;</span></span><span style="font-size: x-small;"> </span><br />
<span style="font-size: x-small;">
</span><br />
<span style="color: green; font-size: x-small;"><br />
<span style="color: green; font-size: x-small;"><br />
-- Declare the cursor for the list of partitions to be processed. <br />
</span><br /></span><span style="color: blue; font-size: x-small;"><span style="color: blue; font-size: x-small;"></span></span><span style="color: blue; font-size: x-small;"><span style="color: blue; font-size: x-small;">DECLARE</span></span><span style="font-size: x-small;"> </span><span style="color: green; font-size: x-small;"><span style="color: green; font-size: x-small;">partitions</span></span><span style="font-size: x-small;"> </span><span style="color: blue; font-size: x-small;"><span style="color: blue; font-size: x-small;">CURSOR</span></span><span style="font-size: x-small;"> </span><span style="color: blue; font-size: x-small;"><span style="color: blue; font-size: x-small;">FOR</span></span><span style="font-size: x-small;"> </span><br />
<span style="font-size: x-small;">
</span><br />
<span style="font-size: x-small;"> </span><span style="color: blue; font-size: x-small;"><span style="color: blue; font-size: x-small;">SELECT</span></span><span style="font-size: x-small;"> </span><span style="color: grey; font-size: x-small;"><span style="color: grey; font-size: x-small;">*</span></span><span style="font-size: x-small;"> </span><br />
<span style="font-size: x-small;">
</span><br />
<span style="font-size: x-small;"> </span><span style="color: blue; font-size: x-small;"><span style="color: blue; font-size: x-small;">FROM</span></span><span style="font-size: x-small;"> #work_to_do</span><span style="color: grey; font-size: x-small;"><span style="color: grey; font-size: x-small;">;</span></span><span style="font-size: x-small;"> </span><br />
<span style="font-size: x-small;">
</span><br />
<span style="color: green; font-size: x-small;"><br />
<span style="color: green; font-size: x-small;"><br />
-- Open the cursor. <br />
</span><br /></span><span style="color: blue; font-size: x-small;"><span style="color: blue; font-size: x-small;"></span></span><span style="color: blue; font-size: x-small;"><span style="color: blue; font-size: x-small;">OPEN</span></span><span style="font-size: x-small;"> </span><span style="color: green; font-size: x-small;"><span style="color: green; font-size: x-small;">partitions</span></span><span style="color: grey; font-size: x-small;"><span style="color: grey; font-size: x-small;">;</span></span><span style="font-size: x-small;"> </span><br />
<span style="font-size: x-small;">
</span><br />
<span style="color: green; font-size: x-small;"><br />
<span style="color: green; font-size: x-small;"><br />
-- Loop through the partitions. <br />
</span><br /></span><span style="color: blue; font-size: x-small;"><span style="color: blue; font-size: x-small;"></span></span><span style="color: blue; font-size: x-small;"><span style="color: blue; font-size: x-small;">WHILE </span></span><span style="color: grey; font-size: x-small;"><span style="color: grey; font-size: x-small;">(</span></span><span style="font-size: x-small;"> 1 </span><span style="color: grey; font-size: x-small;"><span style="color: grey; font-size: x-small;">=</span></span><span style="font-size: x-small;"> 1 </span><span style="color: grey; font-size: x-small;"><span style="color: grey; font-size: x-small;">)</span></span><span style="font-size: x-small;"> </span><br />
<span style="font-size: x-small;">
</span><br />
<span style="font-size: x-small;"> </span><span style="color: blue; font-size: x-small;"><span style="color: blue; font-size: x-small;">BEGIN</span></span><span style="color: grey; font-size: x-small;"><span style="color: grey; font-size: x-small;">;</span></span><span style="font-size: x-small;"> </span><br />
<span style="font-size: x-small;">
</span><br />
<span style="font-size: x-small;"> </span><span style="color: blue; font-size: x-small;"><span style="color: blue; font-size: x-small;">FETCH</span></span><span style="font-size: x-small;"> </span><span style="color: blue; font-size: x-small;"><span style="color: blue; font-size: x-small;">next</span></span><span style="font-size: x-small;"> </span><span style="color: blue; font-size: x-small;"><span style="color: blue; font-size: x-small;">FROM</span></span><span style="font-size: x-small;"> </span><span style="color: green; font-size: x-small;"><span style="color: green; font-size: x-small;">partitions</span></span><span style="font-size: x-small;"> </span><span style="color: blue; font-size: x-small;"><span style="color: blue; font-size: x-small;">INTO</span></span><span style="font-size: x-small;"> @objectid</span><span style="color: grey; font-size: x-small;"><span style="color: grey; font-size: x-small;">,</span></span><span style="font-size: x-small;"> @indexid</span><span style="color: grey; font-size: x-small;"><span style="color: grey; font-size: x-small;">,</span></span><span style="font-size: x-small;"> @partitionnum</span><span style="color: grey; font-size: x-small;"><span style="color: grey; font-size: x-small;">,</span></span><span style="font-size: x-small;"> @frag</span><span style="color: grey; font-size: x-small;"><span style="color: grey; font-size: x-small;">;</span></span><span style="font-size: x-small;"> </span><br />
<span style="font-size: x-small;">
</span><br />
<span style="font-size: x-small;"> </span><span style="color: blue; font-size: x-small;"><span style="color: blue; font-size: x-small;">IF</span></span><span style="font-size: x-small;"> </span><span style="color: magenta; font-size: x-small;"><span style="color: magenta; font-size: x-small;">@@FETCH_STATUS</span></span><span style="font-size: x-small;"> </span><span style="color: grey; font-size: x-small;"><span style="color: grey; font-size: x-small;"><</span></span><span style="font-size: x-small;"> 0 </span><br />
<span style="font-size: x-small;">
</span><br />
<span style="font-size: x-small;"> </span><span style="color: blue; font-size: x-small;"><span style="color: blue; font-size: x-small;">BREAK</span></span><span style="color: grey; font-size: x-small;"><span style="color: grey; font-size: x-small;">;</span></span><span style="font-size: x-small;"> </span><br />
<span style="font-size: x-small;">
</span><br />
<span style="font-size: x-small;"> </span><span style="color: blue; font-size: x-small;"><span style="color: blue; font-size: x-small;">SELECT</span></span><span style="font-size: x-small;"> @objectname </span><span style="color: grey; font-size: x-small;"><span style="color: grey; font-size: x-small;">=</span></span><span style="font-size: x-small;"> </span><span style="color: magenta; font-size: x-small;"><span style="color: magenta; font-size: x-small;">QUOTENAME</span></span><span style="color: grey; font-size: x-small;"><span style="color: grey; font-size: x-small;">(</span></span><span style="font-size: x-small;">o</span><span style="color: grey; font-size: x-small;"><span style="color: grey; font-size: x-small;">.</span></span><span style="font-size: x-small;">NAME</span><span style="color: grey; font-size: x-small;"><span style="color: grey; font-size: x-small;">),</span></span><span style="font-size: x-small;"> </span><br />
<span style="font-size: x-small;">
</span><br />
<span style="font-size: x-small;"> @schemaname </span><span style="color: grey; font-size: x-small;"><span style="color: grey; font-size: x-small;">=</span></span><span style="font-size: x-small;"> </span><span style="color: magenta; font-size: x-small;"><span style="color: magenta; font-size: x-small;">QUOTENAME</span></span><span style="color: grey; font-size: x-small;"><span style="color: grey; font-size: x-small;">(</span></span><span style="font-size: x-small;">s</span><span style="color: grey; font-size: x-small;"><span style="color: grey; font-size: x-small;">.</span></span><span style="font-size: x-small;">NAME</span><span style="color: grey; font-size: x-small;"><span style="color: grey; font-size: x-small;">)</span></span><span style="font-size: x-small;"> </span><br />
<span style="font-size: x-small;">
</span><br />
<span style="font-size: x-small;"> </span><span style="color: blue; font-size: x-small;"><span style="color: blue; font-size: x-small;">FROM</span></span><span style="font-size: x-small;"> </span><span style="color: green; font-size: x-small;"><span style="color: green; font-size: x-small;">sys</span></span><span style="color: grey; font-size: x-small;"><span style="color: grey; font-size: x-small;">.</span></span><span style="color: green; font-size: x-small;"><span style="color: green; font-size: x-small;">OBJECTS</span></span><span style="font-size: x-small;"> </span><span style="color: blue; font-size: x-small;"><span style="color: blue; font-size: x-small;">AS</span></span><span style="font-size: x-small;"> o </span><br />
<span style="font-size: x-small;">
</span><br />
<span style="font-size: x-small;"> </span><span style="color: grey; font-size: x-small;"><span style="color: grey; font-size: x-small;">JOIN</span></span><span style="font-size: x-small;"> </span><span style="color: green; font-size: x-small;"><span style="color: green; font-size: x-small;">sys</span></span><span style="color: grey; font-size: x-small;"><span style="color: grey; font-size: x-small;">.</span></span><span style="color: green; font-size: x-small;"><span style="color: green; font-size: x-small;">SCHEMAS</span></span><span style="font-size: x-small;"> </span><span style="color: blue; font-size: x-small;"><span style="color: blue; font-size: x-small;">AS</span></span><span style="font-size: x-small;"> s </span><br />
<span style="font-size: x-small;">
</span><br />
<span style="font-size: x-small;"> </span><span style="color: blue; font-size: x-small;"><span style="color: blue; font-size: x-small;">ON</span></span><span style="font-size: x-small;"> s</span><span style="color: grey; font-size: x-small;"><span style="color: grey; font-size: x-small;">.</span></span><span style="color: magenta; font-size: x-small;"><span style="color: magenta; font-size: x-small;">SCHEMA_ID</span></span><span style="font-size: x-small;"> </span><span style="color: grey; font-size: x-small;"><span style="color: grey; font-size: x-small;">=</span></span><span style="font-size: x-small;"> o</span><span style="color: grey; font-size: x-small;"><span style="color: grey; font-size: x-small;">.</span></span><span style="color: magenta; font-size: x-small;"><span style="color: magenta; font-size: x-small;">SCHEMA_ID</span></span><span style="font-size: x-small;"> </span><br />
<span style="font-size: x-small;">
</span><br />
<span style="font-size: x-small;"> </span><span style="color: blue; font-size: x-small;"><span style="color: blue; font-size: x-small;">WHERE</span></span><span style="font-size: x-small;"> o</span><span style="color: grey; font-size: x-small;"><span style="color: grey; font-size: x-small;">.</span></span><span style="color: magenta; font-size: x-small;"><span style="color: magenta; font-size: x-small;">OBJECT_ID</span></span><span style="font-size: x-small;"> </span><span style="color: grey; font-size: x-small;"><span style="color: grey; font-size: x-small;">=</span></span><span style="font-size: x-small;"> @objectid</span><span style="color: grey; font-size: x-small;"><span style="color: grey; font-size: x-small;">;</span></span><span style="font-size: x-small;"> </span><br />
<span style="font-size: x-small;">
</span><br />
<span style="font-size: x-small;"> </span><span style="color: blue; font-size: x-small;"><span style="color: blue; font-size: x-small;">SELECT</span></span><span style="font-size: x-small;"> @indexname </span><span style="color: grey; font-size: x-small;"><span style="color: grey; font-size: x-small;">=</span></span><span style="font-size: x-small;"> </span><span style="color: magenta; font-size: x-small;"><span style="color: magenta; font-size: x-small;">QUOTENAME</span></span><span style="color: grey; font-size: x-small;"><span style="color: grey; font-size: x-small;">(</span></span><span style="font-size: x-small;">NAME</span><span style="color: grey; font-size: x-small;"><span style="color: grey; font-size: x-small;">)</span></span><span style="font-size: x-small;"> </span><br />
<span style="font-size: x-small;">
</span><br />
<span style="font-size: x-small;"> </span><span style="color: blue; font-size: x-small;"><span style="color: blue; font-size: x-small;">FROM</span></span><span style="font-size: x-small;"> </span><span style="color: green; font-size: x-small;"><span style="color: green; font-size: x-small;">sys</span></span><span style="color: grey; font-size: x-small;"><span style="color: grey; font-size: x-small;">.</span></span><span style="color: green; font-size: x-small;"><span style="color: green; font-size: x-small;">INDEXES</span></span><span style="font-size: x-small;"> </span><br />
<span style="font-size: x-small;">
</span><br />
<span style="font-size: x-small;"> </span><span style="color: blue; font-size: x-small;"><span style="color: blue; font-size: x-small;">WHERE</span></span><span style="font-size: x-small;"> </span><span style="color: magenta; font-size: x-small;"><span style="color: magenta; font-size: x-small;">OBJECT_ID</span></span><span style="font-size: x-small;"> </span><span style="color: grey; font-size: x-small;"><span style="color: grey; font-size: x-small;">=</span></span><span style="font-size: x-small;"> @objectid </span><br />
<span style="font-size: x-small;">
</span><br />
<span style="font-size: x-small;"> </span><span style="color: grey; font-size: x-small;"><span style="color: grey; font-size: x-small;">AND</span></span><span style="font-size: x-small;"> INDEX_ID </span><span style="color: grey; font-size: x-small;"><span style="color: grey; font-size: x-small;">=</span></span><span style="font-size: x-small;"> @indexid</span><span style="color: grey; font-size: x-small;"><span style="color: grey; font-size: x-small;">;</span></span><span style="font-size: x-small;"> </span><br />
<span style="font-size: x-small;">
</span><br />
<span style="font-size: x-small;"> </span><span style="color: blue; font-size: x-small;"><span style="color: blue; font-size: x-small;">SELECT</span></span><span style="font-size: x-small;"> @partitioncount </span><span style="color: grey; font-size: x-small;"><span style="color: grey; font-size: x-small;">=</span></span><span style="font-size: x-small;"> </span><span style="color: magenta; font-size: x-small;"><span style="color: magenta; font-size: x-small;">COUNT</span></span><span style="color: blue; font-size: x-small;"><span style="color: blue; font-size: x-small;"> </span></span><span style="color: grey; font-size: x-small;"><span style="color: grey; font-size: x-small;">(*)</span></span><span style="font-size: x-small;"> </span><br />
<span style="font-size: x-small;">
</span><br />
<span style="font-size: x-small;"> </span><span style="color: blue; font-size: x-small;"><span style="color: blue; font-size: x-small;">FROM</span></span><span style="font-size: x-small;"> </span><span style="color: green; font-size: x-small;"><span style="color: green; font-size: x-small;">sys</span></span><span style="color: grey; font-size: x-small;"><span style="color: grey; font-size: x-small;">.</span></span><span style="color: green; font-size: x-small;"><span style="color: green; font-size: x-small;">PARTITIONS</span></span><span style="font-size: x-small;"> </span><br />
<span style="font-size: x-small;">
</span><br />
<span style="font-size: x-small;"> </span><span style="color: blue; font-size: x-small;"><span style="color: blue; font-size: x-small;">WHERE</span></span><span style="font-size: x-small;"> </span><span style="color: magenta; font-size: x-small;"><span style="color: magenta; font-size: x-small;">OBJECT_ID</span></span><span style="font-size: x-small;"> </span><span style="color: grey; font-size: x-small;"><span style="color: grey; font-size: x-small;">=</span></span><span style="font-size: x-small;"> @objectid </span><br />
<span style="font-size: x-small;">
</span><br />
<span style="font-size: x-small;"> </span><span style="color: grey; font-size: x-small;"><span style="color: grey; font-size: x-small;">AND</span></span><span style="font-size: x-small;"> INDEX_ID </span><span style="color: grey; font-size: x-small;"><span style="color: grey; font-size: x-small;">=</span></span><span style="font-size: x-small;"> @indexid</span><span style="color: grey; font-size: x-small;"><span style="color: grey; font-size: x-small;">;</span></span><span style="font-size: x-small;"> </span><br />
<span style="font-size: x-small;">
</span><br />
<span style="font-size: x-small;"> </span><span style="color: green; font-size: x-small;"><span style="color: green; font-size: x-small;">-- 30 is an arbitrary decision point at which to switch between reorganizing and rebuilding. </span></span><br />
<span style="color: green; font-size: x-small;"><span style="color: green; font-size: x-small;">
</span></span><span style="font-size: x-small;"></span><br />
<span style="font-size: x-small;"> </span><span style="color: blue; font-size: x-small;"><span style="color: blue; font-size: x-small;">IF</span></span><span style="font-size: x-small;"> @frag </span><span style="color: grey; font-size: x-small;"><span style="color: grey; font-size: x-small;"><</span></span><span style="font-size: x-small;"> 30.0 </span><br />
<span style="font-size: x-small;">
</span><br />
<span style="font-size: x-small;"> </span><span style="color: blue; font-size: x-small;"><span style="color: blue; font-size: x-small;">SET</span></span><span style="font-size: x-small;"> @command </span><span style="color: grey; font-size: x-small;"><span style="color: grey; font-size: x-small;">=</span></span><span style="font-size: x-small;"> </span><span style="color: red; font-size: x-small;"><span style="color: red; font-size: x-small;">N'ALTER INDEX '</span></span><span style="font-size: x-small;"> </span><span style="color: grey; font-size: x-small;"><span style="color: grey; font-size: x-small;">+</span></span><span style="font-size: x-small;"> @indexname </span><span style="color: grey; font-size: x-small;"><span style="color: grey; font-size: x-small;">+</span></span><span style="font-size: x-small;"> </span><span style="color: red; font-size: x-small;"><span style="color: red; font-size: x-small;">N' ON '</span></span><span style="font-size: x-small;"> </span><br />
<span style="font-size: x-small;">
</span><br />
<span style="font-size: x-small;"> </span><span style="color: grey; font-size: x-small;"><span style="color: grey; font-size: x-small;">+</span></span><span style="font-size: x-small;"> @schemaname </span><span style="color: grey; font-size: x-small;"><span style="color: grey; font-size: x-small;">+</span></span><span style="font-size: x-small;"> </span><span style="color: red; font-size: x-small;"><span style="color: red; font-size: x-small;">N'.'</span></span><span style="font-size: x-small;"> </span><span style="color: grey; font-size: x-small;"><span style="color: grey; font-size: x-small;">+</span></span><span style="font-size: x-small;"> @objectname </span><span style="color: grey; font-size: x-small;"><span style="color: grey; font-size: x-small;">+</span></span><span style="font-size: x-small;"> </span><span style="color: red; font-size: x-small;"><span style="color: red; font-size: x-small;">N' REORGANIZE'</span></span><span style="color: grey; font-size: x-small;"><span style="color: grey; font-size: x-small;">;</span></span><span style="font-size: x-small;"> </span><br />
<span style="font-size: x-small;">
</span><br />
<span style="font-size: x-small;"> </span><span style="color: blue; font-size: x-small;"><span style="color: blue; font-size: x-small;">IF</span></span><span style="font-size: x-small;"> @frag </span><span style="color: grey; font-size: x-small;"><span style="color: grey; font-size: x-small;">>=</span></span><span style="font-size: x-small;"> 30.0 </span><br />
<span style="font-size: x-small;">
</span><br />
<span style="font-size: x-small;"> </span><span style="color: blue; font-size: x-small;"><span style="color: blue; font-size: x-small;">SET</span></span><span style="font-size: x-small;"> @command </span><span style="color: grey; font-size: x-small;"><span style="color: grey; font-size: x-small;">=</span></span><span style="font-size: x-small;"> </span><span style="color: red; font-size: x-small;"><span style="color: red; font-size: x-small;">N'ALTER INDEX '</span></span><span style="font-size: x-small;"> </span><span style="color: grey; font-size: x-small;"><span style="color: grey; font-size: x-small;">+</span></span><span style="font-size: x-small;"> @indexname </span><span style="color: grey; font-size: x-small;"><span style="color: grey; font-size: x-small;">+</span></span><span style="font-size: x-small;"> </span><span style="color: red; font-size: x-small;"><span style="color: red; font-size: x-small;">N' ON '</span></span><span style="font-size: x-small;"> </span><br />
<span style="font-size: x-small;">
</span><br />
<span style="font-size: x-small;"> </span><span style="color: grey; font-size: x-small;"><span style="color: grey; font-size: x-small;">+</span></span><span style="font-size: x-small;"> @schemaname </span><span style="color: grey; font-size: x-small;"><span style="color: grey; font-size: x-small;">+</span></span><span style="font-size: x-small;"> </span><span style="color: red; font-size: x-small;"><span style="color: red; font-size: x-small;">N'.'</span></span><span style="font-size: x-small;"> </span><span style="color: grey; font-size: x-small;"><span style="color: grey; font-size: x-small;">+</span></span><span style="font-size: x-small;"> @objectname </span><br />
<span style="font-size: x-small;">
</span><br />
<span style="font-size: x-small;"> </span><span style="color: grey; font-size: x-small;"><span style="color: grey; font-size: x-small;">+</span></span><span style="font-size: x-small;"> </span><span style="color: red; font-size: x-small;"><span style="color: red; font-size: x-small;">N' REBUILD WITH(ONLINE = ON, MAXDOP = 8)'</span></span><span style="color: grey; font-size: x-small;"><span style="color: grey; font-size: x-small;">;</span></span><span style="font-size: x-small;"> </span><br />
<span style="font-size: x-small;">
</span><br />
<span style="font-size: x-small;"> </span><span style="color: blue; font-size: x-small;"><span style="color: blue; font-size: x-small;">IF</span></span><span style="font-size: x-small;"> @partitioncount </span><span style="color: grey; font-size: x-small;"><span style="color: grey; font-size: x-small;">></span></span><span style="font-size: x-small;"> 1 </span><br />
<span style="font-size: x-small;">
</span><br />
<span style="font-size: x-small;"> </span><span style="color: blue; font-size: x-small;"><span style="color: blue; font-size: x-small;">SET</span></span><span style="font-size: x-small;"> @command </span><span style="color: grey; font-size: x-small;"><span style="color: grey; font-size: x-small;">=</span></span><span style="font-size: x-small;"> @command </span><span style="color: grey; font-size: x-small;"><span style="color: grey; font-size: x-small;">+</span></span><span style="font-size: x-small;"> </span><span style="color: red; font-size: x-small;"><span style="color: red; font-size: x-small;">N' PARTITION='</span></span><span style="font-size: x-small;"> </span><br />
<span style="font-size: x-small;">
</span><br />
<span style="font-size: x-small;"> </span><span style="color: grey; font-size: x-small;"><span style="color: grey; font-size: x-small;">+</span></span><span style="font-size: x-small;"> </span><span style="color: magenta; font-size: x-small;"><span style="color: magenta; font-size: x-small;">CAST</span></span><span style="color: grey; font-size: x-small;"><span style="color: grey; font-size: x-small;">(</span></span><span style="font-size: x-small;">@partitionnum </span><span style="color: blue; font-size: x-small;"><span style="color: blue; font-size: x-small;">AS</span></span><span style="font-size: x-small;"> </span><span style="color: blue; font-size: x-small;"><span style="color: blue; font-size: x-small;">NVARCHAR</span></span><span style="color: grey; font-size: x-small;"><span style="color: grey; font-size: x-small;">(</span></span><span style="font-size: x-small;">10</span><span style="color: grey; font-size: x-small;"><span style="color: grey; font-size: x-small;">));</span></span><span style="font-size: x-small;"> </span><br />
<span style="font-size: x-small;">
</span><br />
<span style="font-size: x-small;"> </span><span style="color: blue; font-size: x-small;"><span style="color: blue; font-size: x-small;">begin</span></span><span style="font-size: x-small;"> </span><span style="color: blue; font-size: x-small;"><span style="color: blue; font-size: x-small;">try</span></span><span style="font-size: x-small;"> </span><br />
<span style="font-size: x-small;">
</span><br />
<span style="font-size: x-small;"> </span><span style="color: blue; font-size: x-small;"><span style="color: blue; font-size: x-small;">EXEC </span></span><span style="color: grey; font-size: x-small;"><span style="color: grey; font-size: x-small;">(</span></span><span style="font-size: x-small;">@command</span><span style="color: grey; font-size: x-small;"><span style="color: grey; font-size: x-small;">);</span></span><span style="font-size: x-small;"> </span><br />
<span style="font-size: x-small;">
</span><br />
<span style="font-size: x-small;"> </span><span style="color: blue; font-size: x-small;"><span style="color: blue; font-size: x-small;">end</span></span><span style="font-size: x-small;"> </span><span style="color: blue; font-size: x-small;"><span style="color: blue; font-size: x-small;">try</span></span><span style="font-size: x-small;"> </span><br />
<span style="font-size: x-small;">
</span><br />
<span style="font-size: x-small;"> </span><span style="color: blue; font-size: x-small;"><span style="color: blue; font-size: x-small;">begin</span></span><span style="font-size: x-small;"> </span><span style="color: blue; font-size: x-small;"><span style="color: blue; font-size: x-small;">catch</span></span><br />
<span style="color: blue; font-size: x-small;"><span style="color: blue; font-size: x-small;">
</span></span><span style="font-size: x-small;"></span><br />
<span style="font-size: x-small;"> </span><span style="color: blue; font-size: x-small;"><span style="color: blue; font-size: x-small;">print</span></span><span style="font-size: x-small;"> </span><span style="color: red; font-size: x-small;"><span style="color: red; font-size: x-small;">'whoops'</span></span><br />
<span style="color: red; font-size: x-small;"><span style="color: red; font-size: x-small;">
</span></span><span style="font-size: x-small;"></span><br />
<span style="font-size: x-small;"> </span><span style="color: blue; font-size: x-small;"><span style="color: blue; font-size: x-small;">end</span></span><span style="font-size: x-small;"> </span><span style="color: blue; font-size: x-small;"><span style="color: blue; font-size: x-small;">catch</span></span><br />
<span style="color: blue; font-size: x-small;"><span style="color: blue; font-size: x-small;">
</span></span><br />
<span style="font-size: x-small;"><br />
<br />
</span><span style="font-size: x-small;"> </span><span style="color: blue; font-size: x-small;"><span style="color: blue; font-size: x-small;">PRINT</span></span><span style="font-size: x-small;"> </span><span style="color: red; font-size: x-small;"><span style="color: red; font-size: x-small;">N'Executed: '</span></span><span style="font-size: x-small;"> </span><span style="color: grey; font-size: x-small;"><span style="color: grey; font-size: x-small;">+</span></span><span style="font-size: x-small;"> @command</span><span style="color: grey; font-size: x-small;"><span style="color: grey; font-size: x-small;">;</span></span><span style="font-size: x-small;"> </span><br />
<span style="font-size: x-small;">
</span><br />
<span style="font-size: x-small;"> </span><span style="color: blue; font-size: x-small;"><span style="color: blue; font-size: x-small;">END</span></span><span style="color: grey; font-size: x-small;"><span style="color: grey; font-size: x-small;">;</span></span><span style="font-size: x-small;"> </span><br />
<span style="font-size: x-small;">
</span><br />
<span style="color: green; font-size: x-small;"><br />
<span style="color: green; font-size: x-small;"><br />
-- Close and deallocate the cursor. <br />
</span><br /></span><span style="color: blue; font-size: x-small;"><span style="color: blue; font-size: x-small;"></span></span><span style="color: blue; font-size: x-small;"><span style="color: blue; font-size: x-small;">CLOSE</span></span><span style="font-size: x-small;"> </span><span style="color: green; font-size: x-small;"><span style="color: green; font-size: x-small;">partitions</span></span><span style="color: grey; font-size: x-small;"><span style="color: grey; font-size: x-small;">;</span></span><span style="font-size: x-small;"> </span><br />
<span style="font-size: x-small;">
</span><span style="color: blue; font-size: x-small;"><span style="color: blue; font-size: x-small;"></span></span><br />
<span style="color: blue; font-size: x-small;"><span style="color: blue; font-size: x-small;">DEALLOCATE</span></span><span style="font-size: x-small;"> </span><span style="color: green; font-size: x-small;"><span style="color: green; font-size: x-small;">partitions</span></span><span style="color: grey; font-size: x-small;"><span style="color: grey; font-size: x-small;">;</span></span><span style="font-size: x-small;"> </span><br />
<span style="font-size: x-small;">
</span><br />
<span style="color: green; font-size: x-small;"><br />
<span style="color: green; font-size: x-small;"><br />
-- Drop the temporary table. <br />
</span><br /></span><span style="color: blue; font-size: x-small;"><span style="color: blue; font-size: x-small;"></span></span><span style="color: blue; font-size: x-small;"><span style="color: blue; font-size: x-small;">DROP</span></span><span style="font-size: x-small;"> </span><span style="color: blue; font-size: x-small;"><span style="color: blue; font-size: x-small;">TABLE</span></span><span style="font-size: x-small;"> #work_to_do</span><span style="color: grey; font-size: x-small;"><span style="color: grey; font-size: x-small;">;</span></span><span style="font-size: x-small;"> </span><br />
<span style="font-size: x-small;">
</span><span style="color: blue; font-size: x-small;"><span style="color: blue; font-size: x-small;"></span></span><br />
<span style="color: blue; font-size: x-small;"><span style="color: blue; font-size: x-small;">GO</span></span><span style="font-size: x-small;"> </span><br />
<br />
<span style="font-size: x-small;">
<br />
<br />
</span><span style="color: maroon; font-size: x-small;"><span style="color: maroon; font-size: x-small;">sp_updatestats</span></span></div>
Prasanhttp://www.blogger.com/profile/12994242712106741793noreply@blogger.com0tag:blogger.com,1999:blog-3099421127115759789.post-17067751137962744392017-05-03T15:38:00.003+05:302017-05-03T15:38:30.577+05:30List of table Ids in AX- SQL dictionary<div dir="ltr" style="text-align: left;" trbidi="on">
Hi,<br />
<br /><br />
If you ever want to know where all table Id of AX tables are stored? here is the answer its SQLDICTIONARY<br />
<br /><br />
here is a query to know the table ID for VendTable<br />
<div style="text-align: left;">
<br /></div>
<div style="text-align: left;">
<span style="font-size: large;"> select tabId from sql where sql.sqlName=='VendTable' </span></div>
<div style="text-align: left;">
<span style="font-size: large;">
&& sql.array==0;</span></div>
<div style="text-align: left;">
<br /></div>
<div style="text-align: left;">
Hope this Helps!</div>
<div style="text-align: left;">
<span style="font-size: small;">Prasan</span></div>
</div>
Prasanhttp://www.blogger.com/profile/12994242712106741793noreply@blogger.com0tag:blogger.com,1999:blog-3099421127115759789.post-69427294421613911932017-03-14T16:59:00.000+05:302017-03-14T17:01:16.689+05:30Power BI documents<div dir="ltr" style="text-align: left;" trbidi="on">
Hi,<br />
<br />
Found some interesting topics that would help to explore much on data analysis and reporting.<br />
<br />
Microsoft Power BI Documents<br />
<br />
Introducing Microsoft Power BI, by Marco Russo and Alberto Ferrari:<br />
<a href="http://www.sqlbi.com/books/introducing-microsoft-power-bi/" km.title="" ms.cmpgrp="" ms.cmpnm="http://www.sqlbi.com/books/introducing-microsoft-power-bi/" ms.cmptyp="link" ms.interactiontype="1" ms.pgarea="" ms.title="" rel="nofollow noopener noreferrer" target="_blank">http://www.sqlbi.com/books/introducing-microsoft-p<wbr></wbr>ower-bi/</a><br />
<br />
<div style="margin: 0in 0in 0pt;">
<span style="font-family: "calibri" , sans-serif; font-size: 11pt;"><span style="color: black;">Power BI tutorial videos from Adam Saxton:</span></span></div>
<div style="margin: 0in 0in 0pt;">
<span style="font-family: "calibri" , sans-serif; font-size: 11pt;"><a href="https://guyinacube.com/videos" km.title="" ms.cmpgrp="" ms.cmpnm="https://guyinacube.com/videos" ms.cmptyp="link" ms.interactiontype="1" ms.pgarea="" ms.title="" rel="nofollow noopener noreferrer" target="_blank"><span style="color: #0563c1;">https://guyinacube.com/videos</span></a></span></div>
<div style="margin: 0in 0in 0pt;">
<span style="font-family: "calibri" , sans-serif; font-size: 11pt;"><a href="https://www.youtube.com/guyinacube" km.title="" ms.cmpgrp="" ms.cmpnm="https://www.youtube.com/guyinacube" ms.cmptyp="link" ms.interactiontype="1" ms.pgarea="" ms.title="" rel="nofollow noopener noreferrer" target="_blank"><span style="color: #0563c1;">https://www.youtube.com/guyinacube</span></a></span></div>
<div style="margin: 0in 0in 0pt;">
<span style="font-family: "calibri" , sans-serif; font-size: 11pt;"></span> </div>
<div style="margin: 0in 0in 0pt;">
<span style="font-family: "calibri" , sans-serif; font-size: 11pt;">hope you get on to this.</span></div>
<div style="margin: 0in 0in 0pt;">
<span style="font-family: "calibri" , sans-serif; font-size: 11pt;"></span> </div>
<div style="margin: 0in 0in 0pt;">
<span style="font-family: "calibri" , sans-serif; font-size: 11pt;">Thanks,</span></div>
<div style="margin: 0in 0in 0pt;">
<span style="font-family: "calibri" , sans-serif; font-size: 11pt;">Prasan</span></div>
</div>
Prasanhttp://www.blogger.com/profile/12994242712106741793noreply@blogger.com1tag:blogger.com,1999:blog-3099421127115759789.post-71885378496886261732017-03-14T00:11:00.002+05:302017-03-14T00:11:58.509+05:30Dynamics AX 7 Wikipedia<div dir="ltr" style="text-align: left;" trbidi="on">
Hi folks,<br />
<br />
Below is the link where you can find documentation of AX 7.0 and dynamics 365 for operations. Happy Daxing!!<br />
<br />
<a href="https://ax.help.dynamics.com/en/">https://ax.help.dynamics.com/en/</a><br />
<br />
Thanks,<br />
Prasan<br />
<br /></div>
Prasanhttp://www.blogger.com/profile/12994242712106741793noreply@blogger.com1tag:blogger.com,1999:blog-3099421127115759789.post-64262400730269017732015-09-29T09:37:00.000+05:302015-09-29T09:37:10.678+05:30AX2012- Opening an url form AX X++ code<div dir="ltr" style="text-align: left;" trbidi="on">
Infolog.lookupurl("<a href="http://www.google.com/">www.google.com</a>");<br />
<br />
<br />
this statement will quickly open google website in default browser.<br />
<br />
<br />
Hope this helps,<br />
Prasan</div>
Prasanhttp://www.blogger.com/profile/12994242712106741793noreply@blogger.com0tag:blogger.com,1999:blog-3099421127115759789.post-68273505299508876642015-09-29T09:35:00.003+05:302015-09-29T09:38:49.612+05:30AX2012- Update/Change FinancialDimension value in X++ code<div dir="ltr" style="text-align: left;" trbidi="on">
<div style="text-align: left;">
<span style="font-family: Arial, Helvetica, sans-serif;">static void PSV_UpdateOpDivDimension_Items(Args _args)</span></div>
<div style="text-align: left;">
<span style="font-family: Arial, Helvetica, sans-serif;">{
</span><br />
<span style="font-family: Arial, Helvetica, sans-serif;">InventTable inventTable;
</span><br />
<span style="font-family: Arial, Helvetica, sans-serif;">DimensionAttributeValueSetStorage dimStorage;
</span><br />
<span style="font-family: Arial, Helvetica, sans-serif;">DimensionAttribute dimAttrOpDiv;
</span><br />
<span style="font-family: Arial, Helvetica, sans-serif;">DimensionAttributeValue dimAttributeValue;</span><br />
<span style="font-family: Arial, Helvetica, sans-serif;">changeCompany('DAT')
</span><br />
<span style="font-family: Arial, Helvetica, sans-serif;">{</span><br />
<span style="font-family: Arial, Helvetica, sans-serif;">while select forUpdate inventTable
</span><br />
<span style="font-family: Arial, Helvetica, sans-serif;">{</span><br />
<span style="font-family: Arial, Helvetica, sans-serif;">ttsBegin;</span><br />
<span style="font-family: Arial, Helvetica, sans-serif;">dimStorage = DimensionAttributeValueSetStorage::find(inventTable.DefaultDimension);</span><br />
<span style="font-family: Arial, Helvetica, sans-serif;">dimAttrOpDiv = DimensionAttribute::findByName("Operating_Division");</span></div>
<div style="text-align: left;">
<span style="font-family: Arial, Helvetica, sans-serif;"></span><br /></div>
<div style="text-align: left;">
<span style="font-family: Arial, Helvetica, sans-serif;">dimAttributeValue = DimensionAttributeValue::findByDimensionAttributeAndValue(dimAttrOpDiv, 'NewValue', true, true);</span></div>
<div style="text-align: left;">
<span style="font-family: Arial, Helvetica, sans-serif;"></span><br /></div>
<div style="text-align: left;">
<span style="font-family: Arial, Helvetica, sans-serif;">dimStorage.addItem(dimAttributeValue);
</span><br />
<span style="font-family: Arial, Helvetica, sans-serif;">inventTable.DefaultDimension = dimStorage.save();
</span><br />
<span style="font-family: Arial, Helvetica, sans-serif;">inventTable.doUpdate();</span><br />
<span style="font-family: Arial, Helvetica, sans-serif;">ttsCommit;</span></div>
<div style="text-align: left;">
<span style="font-family: Arial, Helvetica, sans-serif;">}
</span><br />
<span style="font-family: Arial, Helvetica, sans-serif;">}
</span><br />
<span style="font-family: Arial, Helvetica, sans-serif;">}</span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"></span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"></span><br />
<span style="font-family: Arial, Helvetica, sans-serif;">This code updates the items financial dimensions to new values.</span></div>
<div style="text-align: left;">
<span style="font-family: Arial, Helvetica, sans-serif;"></span><br /></div>
<div style="text-align: left;">
<span style="font-family: Arial, Helvetica, sans-serif;"></span><br /></div>
<div style="text-align: left;">
<span style="font-family: Arial, Helvetica, sans-serif;">hope this helps,</span></div>
<div style="text-align: left;">
<span style="font-family: Arial, Helvetica, sans-serif;">Thanks</span></div>
<div style="text-align: left;">
<span style="font-family: Arial, Helvetica, sans-serif;">Prasan</span></div>
</div>
Prasanhttp://www.blogger.com/profile/12994242712106741793noreply@blogger.com5tag:blogger.com,1999:blog-3099421127115759789.post-36284332757655419242014-09-22T14:58:00.005+05:302014-09-22T14:58:45.034+05:30Updating the value of existing dimesnions - Default dimension<div dir="ltr" style="text-align: left;" trbidi="on">
<span style="color: darkblue; font-family: Consolas; font-size: xx-small;"><span style="color: darkblue; font-family: Consolas; font-size: xx-small;"><span style="color: darkblue; font-family: Consolas; font-size: xx-small;"></span></span></span>Here is a code to update the value of particular dimensions for items<br />
<span style="font-family: Consolas; font-size: xx-small;"><span style="font-family: Consolas; font-size: xx-small;"><span style="font-family: Georgia, "Times New Roman", serif; font-size: small;"></span><br />
<span style="font-family: Georgia, "Times New Roman", serif; font-size: small;"> InventTable inventTable;</span><br />
<span style="font-family: Georgia, "Times New Roman", serif; font-size: small;">
</span><br />
<span style="font-family: Georgia, "Times New Roman", serif; font-size: small;"> DimensionAttributeValueSetStorage dimStorage;</span><br />
<span style="font-family: Georgia, "Times New Roman", serif; font-size: small;">
</span><br />
<span style="font-family: Georgia, "Times New Roman", serif; font-size: small;"> DimensionAttribute dimAttrOpDiv;</span><br />
<span style="font-family: Georgia, "Times New Roman", serif; font-size: small;">
</span><br />
<span style="font-family: Georgia, "Times New Roman", serif; font-size: small;"> DimensionAttributeValue dimAttributeValue;</span><br />
<span style="font-family: Georgia, "Times New Roman", serif; font-size: small;">
</span></span></span><span style="font-family: Georgia, "Times New Roman", serif;"></span><br />
<span style="font-family: Georgia, "Times New Roman", serif;"> <b><span style="color: darkblue;"><span style="color: darkblue;"><span style="color: darkblue;">while</span></span></span></b> <b><span style="color: darkblue;"><span style="color: darkblue;"><span style="color: darkblue;">select</span></span></span></b> <b><span style="color: darkblue;"><span style="color: darkblue;"><span style="color: darkblue;">forUpdate</span></span></span></b> inventTable</span><br />
<span style="font-family: Georgia, "Times New Roman", serif;"></span><br />
<span style="font-family: Georgia, "Times New Roman", serif;">{</span><br />
<span style="font-family: Georgia, "Times New Roman", serif;">
</span><br />
<span style="font-family: Georgia, "Times New Roman", serif;"> <b><span style="color: darkblue;"><span style="color: darkblue;"><span style="color: darkblue;">ttsBegin</span></span></span></b>;</span><br />
<span style="font-family: Georgia, "Times New Roman", serif;">
</span><br />
<span style="font-family: Georgia, "Times New Roman", serif;"> dimStorage = DimensionAttributeValueSetStorage::find(inventTable.DefaultDimension);</span><br />
<span style="font-family: Georgia, "Times New Roman", serif;"></span><br />
<span style="font-family: Georgia, "Times New Roman", serif;"> dimAttrOpDiv = DimensionAttribute::findByName(<span style="color: darkred;"><span style="color: darkred;"><span style="color: darkred;">"DIMENSION NAME</span></span></span>);</span><br />
<span style="font-family: Georgia, "Times New Roman", serif;">
</span><br />
<span style="font-family: Georgia, "Times New Roman", serif;"> dimAttributeValue = DimensionAttributeValue::findByDimensionAttributeAndValue(dimAttrOpDiv, <span style="color: darkred;"><span style="color: darkred;"><span style="color: darkred;">'VALUE'</span></span></span>, <b><span style="color: darkblue;"><span style="color: darkblue;"><span style="color: darkblue;">true</span></span></span></b>, <b><span style="color: darkblue;"><span style="color: darkblue;"><span style="color: darkblue;">true</span></span></span></b>);</span><br />
<span style="font-family: Georgia, "Times New Roman", serif;"></span><br />
<span style="font-family: Georgia, "Times New Roman", serif;"></span><br />
<span style="font-family: Georgia, "Times New Roman", serif;"> dimStorage.addItem(dimAttributeValue);</span><br />
<span style="font-family: Georgia, "Times New Roman", serif;">
</span><br />
<span style="font-family: Georgia, "Times New Roman", serif;"> inventTable.DefaultDimension = dimStorage.save();</span><br />
<span style="font-family: Georgia, "Times New Roman", serif;">
</span><br />
<span style="font-family: Georgia, "Times New Roman", serif;"> inventTable.doUpdate();</span><br />
<span style="font-family: Georgia, "Times New Roman", serif;">
</span><br />
<span style="font-family: Georgia, "Times New Roman", serif;"></span><br />
<span style="font-family: Georgia, "Times New Roman", serif;"> <b><span style="color: darkblue;"><span style="color: darkblue;"><span style="color: darkblue;">ttsCommit</span></span></span></b>;</span><br />
<span style="font-family: Consolas; font-size: xx-small;"><br />
<br />
<span style="font-family: Consolas; font-size: xx-small;"><br />
<br />
<br />
<span style="font-family: Georgia, "Times New Roman", serif; font-size: small;"></span><br />
<span style="font-family: Georgia, "Times New Roman", serif; font-size: small;"> }</span><br />
<span style="font-family: Georgia, "Times New Roman", serif; font-size: small;">
</span><br />
<span style="font-family: Georgia, "Times New Roman", serif; font-size: small;">}</span></span><br /></span><br /></div>
Prasanhttp://www.blogger.com/profile/12994242712106741793noreply@blogger.com0tag:blogger.com,1999:blog-3099421127115759789.post-42184194276668397832014-07-24T12:37:00.001+05:302014-07-24T12:37:17.932+05:30Code to check the current user have system administartor rights in AX X++ code<div dir="ltr" style="text-align: left;" trbidi="on">
Hi,<br />
<br /><br />
Sometime before I was written a big statement to find out the System admin rights of current user. Later I realized about global function that will help us to find the same.<br />
<br /><br />
<strong>isSystemAdministrator():</strong> will tell you the current user is having the admin rights or not.<br />
<br /><br />
if isSystemAdministrator() return true then the user is having system admin rights, else not a system admin.<br />
<br /><br />
Hope this helps you.<br />
Prasn</div>
Prasanhttp://www.blogger.com/profile/12994242712106741793noreply@blogger.com0tag:blogger.com,1999:blog-3099421127115759789.post-45896352832105661662013-07-30T17:32:00.001+05:302013-07-30T17:32:47.707+05:30Finding the current company curreny code in AX 2012<div dir="ltr" style="text-align: left;" trbidi="on">
<span style="font-family: Verdana, sans-serif;">Hello,</span><br />
<span style="font-family: Verdana, sans-serif;"></span><br />
<span style="font-family: Verdana, sans-serif;">Here is the code to find the company currency code in AX 2012</span><br />
<span style="font-family: Verdana, sans-serif;"></span><br />
<strong><span style="font-family: Verdana, sans-serif;">Method 1:</span></strong><br />
<span style="font-family: Verdana, sans-serif;">currencyCode = Ledger::accountingCurrency(CompanyInfo::current());</span><br />
<span style="font-family: Verdana, sans-serif;"></span><br />
<strong><span style="font-family: Verdana, sans-serif;">Method 2:</span></strong><br />
<span style="font-family: Verdana, sans-serif;">currencyCode = Ledger::accountingCurrency(CompanyInfo::Find().recid);</span><br />
<span style="font-family: Verdana, sans-serif;"></span><br />
<strong><span style="font-family: Verdana, sans-serif;">Method 3:</span></strong><br />
<span style="font-family: Verdana, sans-serif;">currencyCode = CompanyInfo::standardCurrency();</span><br />
<span style="font-family: Verdana, sans-serif;">Thanks, </span><br />
<span style="font-family: Verdana, sans-serif;">Prasan</span></div>
Prasanhttp://www.blogger.com/profile/12994242712106741793noreply@blogger.com2tag:blogger.com,1999:blog-3099421127115759789.post-11502038581924479012013-06-19T18:59:00.000+05:302013-06-19T18:59:23.204+05:30AX 2012 – SSRS Reporting : Selecting the report design at the runtime based on the static parameter (dialog field) values<div dir="ltr" style="text-align: left;" trbidi="on">
<span style="font-family: Consolas;"><span style="font-family: Consolas;"> <span style="font-family: Times New Roman;">
</span><br />
<div class="MsoNormal" style="margin: 0in 0in 0pt;">
<span style="font-family: "Segoe UI","sans-serif";">Hi,<o:p></o:p></span></div>
<span style="font-family: Times New Roman;">
</span><br />
<div class="MsoNormal" style="margin: 0in 0in 0pt;">
<span style="font-family: "Segoe UI","sans-serif";">Here
is a solution to select the design at the runtime based on dialog field values in
AX 2012 SSRS reports. Hope this will help you.<o:p></o:p></span></div>
<span style="font-family: Times New Roman;">
</span><br />
<span style="font-family: Times New Roman;">
</span><div class="MsoNormal" style="margin: 0in 0in 0pt;">
<span style="font-family: "Segoe UI","sans-serif";"><o:p></o:p></span> </div>
<span style="font-family: Times New Roman;">
</span><div class="MsoNormal" style="margin: 0in 0in 0pt; mso-layout-grid-align: none;">
<span style="font-family: "Segoe UI","sans-serif";">Create a <b style="mso-bidi-font-weight: normal;">controller</b> class that <b style="mso-bidi-font-weight: normal;">extends</b> </span><b style="mso-bidi-font-weight: normal;"><span style="font-family: "Segoe UI","sans-serif"; mso-fareast-font-family: Calibri; mso-fareast-theme-font: minor-latin;">SrsReportRunController()</span></b><span style="font-family: "Segoe UI","sans-serif"; mso-fareast-font-family: Calibri; mso-fareast-theme-font: minor-latin;"><o:p></o:p></span></div>
<span style="font-family: Times New Roman;">
</span><div class="MsoNormal" style="margin: 0in 0in 0pt;">
<span style="font-family: "Segoe UI","sans-serif";"><o:p> </o:p></span></div>
<span style="font-family: Times New Roman;">
</span><div class="MsoNormal" style="margin: 0in 0in 0pt; mso-layout-grid-align: none;">
<span style="color: darkblue; font-family: "Segoe UI","sans-serif"; mso-bidi-font-weight: bold; mso-fareast-font-family: Calibri; mso-fareast-theme-font: minor-latin;">And override </span><b style="mso-bidi-font-weight: normal;"><span style="font-family: "Segoe UI","sans-serif"; mso-fareast-font-family: Calibri; mso-fareast-theme-font: minor-latin;">preRunModifyContract() </span></b><span style="font-family: "Segoe UI","sans-serif"; mso-fareast-font-family: Calibri; mso-fareast-theme-font: minor-latin;">in the controller() class and follow
the below steps.<span style="color: darkblue; mso-bidi-font-weight: bold;"><o:p></o:p></span></span></div>
<span style="font-family: Times New Roman;">
</span><div class="MsoNormal" style="margin: 0in 0in 0pt; mso-layout-grid-align: none;">
<span style="color: darkblue; font-family: "Segoe UI","sans-serif"; mso-bidi-font-weight: bold; mso-fareast-font-family: Calibri; mso-fareast-theme-font: minor-latin;"><o:p> </o:p></span></div>
<span style="font-family: Times New Roman;">
</span><div class="MsoNormal" style="margin: 0in 0in 0pt; mso-layout-grid-align: none;">
<span style="color: darkblue; font-family: "Segoe UI","sans-serif"; mso-bidi-font-weight: bold; mso-fareast-font-family: Calibri; mso-fareast-theme-font: minor-latin;">protected</span><span style="font-family: "Segoe UI","sans-serif"; mso-fareast-font-family: Calibri; mso-fareast-theme-font: minor-latin;"> <span style="color: darkblue; mso-bidi-font-weight: bold;">void</span>
preRunModifyContract()<o:p></o:p></span></div>
<span style="font-family: Times New Roman;">
</span><div class="MsoNormal" style="margin: 0in 0in 0pt; mso-layout-grid-align: none;">
<span style="font-family: "Segoe UI","sans-serif"; mso-fareast-font-family: Calibri; mso-fareast-theme-font: minor-latin;">{<o:p></o:p></span></div>
<span style="font-family: Times New Roman;">
</span><div class="MsoNormal" style="margin: 0in 0in 0pt; mso-layout-grid-align: none;">
<span style="font-family: "Segoe UI","sans-serif"; mso-fareast-font-family: Calibri; mso-fareast-theme-font: minor-latin;"><span style="mso-spacerun: yes;">
</span><span style="color: darkblue; mso-bidi-font-weight: bold;">boolean</span><span style="mso-spacerun: yes;"> </span>paramValue1;<o:p></o:p></span></div>
<span style="font-family: Times New Roman;">
</span><div class="MsoNormal" style="margin: 0in 0in 0pt; mso-layout-grid-align: none;">
<span style="font-family: "Segoe UI","sans-serif"; mso-fareast-font-family: Calibri; mso-fareast-theme-font: minor-latin;"><span style="mso-spacerun: yes;">
</span><span style="color: darkblue; mso-bidi-font-weight: bold;">boolean</span><span style="mso-spacerun: yes;"> </span>paramValue2;<o:p></o:p></span></div>
<span style="font-family: Times New Roman;">
</span><div class="MsoNormal" style="margin: 0in 0in 0pt; mso-layout-grid-align: none;">
<span style="font-family: "Segoe UI","sans-serif"; mso-fareast-font-family: Calibri; mso-fareast-theme-font: minor-latin;"><o:p> </o:p></span></div>
<span style="font-family: Times New Roman;">
</span><div class="MsoNormal" style="margin: 0in 0in 0pt; mso-layout-grid-align: none;">
<span style="font-family: "Segoe UI","sans-serif"; mso-fareast-font-family: Calibri; mso-fareast-theme-font: minor-latin;"><span style="mso-spacerun: yes;">
</span>SrsReportDataContract dataContract = this.parmReportContract();<o:p></o:p></span></div>
<span style="font-family: Times New Roman;">
</span><div class="MsoNormal" style="margin: 0in 0in 0pt; mso-layout-grid-align: none;">
<span style="font-family: "Segoe UI","sans-serif"; mso-fareast-font-family: Calibri; mso-fareast-theme-font: minor-latin;"><span style="mso-spacerun: yes;">
</span>SrsReportRdlDataContract contract = dataContract.parmRdlContract();<o:p></o:p></span></div>
<span style="font-family: Times New Roman;">
</span><div class="MsoNormal" style="margin: 0in 0in 0pt; mso-layout-grid-align: none;">
<span style="font-family: "Segoe UI","sans-serif"; mso-fareast-font-family: Calibri; mso-fareast-theme-font: minor-latin;"><o:p> </o:p></span></div>
<span style="font-family: Times New Roman;">
</span><div class="MsoNormal" style="margin: 0in 0in 0pt; mso-layout-grid-align: none;">
<span style="font-family: "Segoe UI","sans-serif"; mso-fareast-font-family: Calibri; mso-fareast-theme-font: minor-latin;"><span style="mso-spacerun: yes;">
</span>paramValue1 = contract.getValue(Param1_name);<o:p></o:p></span></div>
<span style="font-family: Times New Roman;">
</span><div class="MsoNormal" style="margin: 0in 0in 0pt; mso-layout-grid-align: none;">
<span style="font-family: "Segoe UI","sans-serif"; mso-fareast-font-family: Calibri; mso-fareast-theme-font: minor-latin;"><span style="mso-spacerun: yes;">
</span>paramValue2 = contract.getValue(Param2_name);<o:p></o:p></span></div>
<span style="font-family: Times New Roman;">
</span><div class="MsoNormal" style="margin: 0in 0in 0pt; mso-layout-grid-align: none;">
<span style="font-family: "Segoe UI","sans-serif"; mso-fareast-font-family: Calibri; mso-fareast-theme-font: minor-latin;"><span style="mso-spacerun: yes;">
</span><o:p></o:p></span></div>
<span style="font-family: Times New Roman;">
</span><div class="MsoNormal" style="margin: 0in 0in 0pt; mso-layout-grid-align: none;">
<span style="font-family: "Segoe UI","sans-serif"; mso-fareast-font-family: Calibri; mso-fareast-theme-font: minor-latin;"><span style="mso-spacerun: yes;">
</span><span style="color: darkblue; mso-bidi-font-weight: bold;">if</span>(paramValue1)<o:p></o:p></span></div>
<span style="font-family: Times New Roman;">
</span><div class="MsoNormal" style="margin: 0in 0in 0pt; mso-layout-grid-align: none;">
<span style="font-family: "Segoe UI","sans-serif"; mso-fareast-font-family: Calibri; mso-fareast-theme-font: minor-latin;"><span style="mso-spacerun: yes;">
</span>{<o:p></o:p></span></div>
<span style="font-family: Times New Roman;">
</span><div class="MsoNormal" style="margin: 0in 0in 0pt; mso-layout-grid-align: none;">
<span style="font-family: "Segoe UI","sans-serif"; mso-fareast-font-family: Calibri; mso-fareast-theme-font: minor-latin;"><span style="mso-spacerun: yes;"> </span>dataContract.parmReportName(reportname.design_1);<o:p></o:p></span></div>
<span style="font-family: Times New Roman;">
</span><div class="MsoNormal" style="margin: 0in 0in 0pt; mso-layout-grid-align: none;">
<span style="font-family: "Segoe UI","sans-serif"; mso-fareast-font-family: Calibri; mso-fareast-theme-font: minor-latin;"><span style="mso-spacerun: yes;">
</span>}<o:p></o:p></span></div>
<span style="font-family: Times New Roman;">
</span><div class="MsoNormal" style="margin: 0in 0in 0pt; mso-layout-grid-align: none;">
<span style="font-family: "Segoe UI","sans-serif"; mso-fareast-font-family: Calibri; mso-fareast-theme-font: minor-latin;"><span style="mso-spacerun: yes;">
</span><span style="color: darkblue; mso-bidi-font-weight: bold;">else</span> <span style="color: darkblue; mso-bidi-font-weight: bold;">if</span>(paramValue2)<o:p></o:p></span></div>
<span style="font-family: Times New Roman;">
</span><div class="MsoNormal" style="margin: 0in 0in 0pt; mso-layout-grid-align: none;">
<span style="font-family: "Segoe UI","sans-serif"; mso-fareast-font-family: Calibri; mso-fareast-theme-font: minor-latin;"><span style="mso-spacerun: yes;">
</span>{<o:p></o:p></span></div>
<span style="font-family: Times New Roman;">
</span><div class="MsoNormal" style="margin: 0in 0in 0pt; mso-layout-grid-align: none;">
<span style="font-family: "Segoe UI","sans-serif"; mso-fareast-font-family: Calibri; mso-fareast-theme-font: minor-latin;"><span style="mso-spacerun: yes;"> </span>dataContract.parmReportName(reportname.design_2);<o:p></o:p></span></div>
<span style="font-family: Times New Roman;">
</span><div class="MsoNormal" style="margin: 0in 0in 0pt; mso-layout-grid-align: none;">
<span style="font-family: "Segoe UI","sans-serif"; mso-fareast-font-family: Calibri; mso-fareast-theme-font: minor-latin;"><span style="mso-spacerun: yes;">
</span>}<o:p></o:p></span></div>
<span style="font-family: Times New Roman;">
</span><div class="MsoNormal" style="margin: 0in 0in 0pt; mso-layout-grid-align: none;">
<span style="font-family: "Segoe UI","sans-serif"; mso-fareast-font-family: Calibri; mso-fareast-theme-font: minor-latin;"><span style="mso-spacerun: yes;"> </span><span style="mso-spacerun: yes;"> </span><span style="mso-spacerun: yes;"> </span>// else default design is used to display the report
which is used in main(); or you can specify your design name here<o:p></o:p></span></div>
<span style="font-family: Times New Roman;">
</span><div class="MsoNormal" style="margin: 0in 0in 0pt; mso-layout-grid-align: none;">
<span style="font-family: "Segoe UI","sans-serif"; mso-fareast-font-family: Calibri; mso-fareast-theme-font: minor-latin;">}<o:p></o:p></span></div>
<span style="font-family: Times New Roman;">
</span><div class="MsoNormal" style="margin: 0in 0in 0pt;">
<span style="font-family: "Segoe UI","sans-serif";"><o:p> </o:p></span></div>
<span style="font-family: Times New Roman;">
</span><div class="MsoNormal" style="margin: 0in 0in 0pt; mso-layout-grid-align: none;">
<span style="color: darkblue; font-family: "Segoe UI","sans-serif"; mso-bidi-font-weight: bold; mso-fareast-font-family: Calibri; mso-fareast-theme-font: minor-latin;">static</span><span style="font-family: "Segoe UI","sans-serif"; mso-fareast-font-family: Calibri; mso-fareast-theme-font: minor-latin;"> <span style="color: darkblue; mso-bidi-font-weight: bold;">void</span> main(Args _args)<o:p></o:p></span></div>
<span style="font-family: Times New Roman;">
</span><div class="MsoNormal" style="margin: 0in 0in 0pt; mso-layout-grid-align: none;">
<span style="font-family: "Segoe UI","sans-serif"; mso-fareast-font-family: Calibri; mso-fareast-theme-font: minor-latin;">{<o:p></o:p></span></div>
<span style="font-family: Times New Roman;">
</span><div class="MsoNormal" style="margin: 0in 0in 0pt; mso-layout-grid-align: none;">
<span style="font-family: "Segoe UI","sans-serif"; mso-fareast-font-family: Calibri; mso-fareast-theme-font: minor-latin;"><span style="mso-spacerun: yes;">
</span>xxx controller = <span style="color: darkblue; mso-bidi-font-weight: bold;">new</span>
xxx (); // Let us assume the current class as xxx<o:p></o:p></span></div>
<span style="font-family: Times New Roman;">
</span><div class="MsoNormal" style="margin: 0in 0in 0pt; mso-layout-grid-align: none;">
<span style="font-family: "Segoe UI","sans-serif"; mso-fareast-font-family: Calibri; mso-fareast-theme-font: minor-latin;"><o:p> </o:p></span></div>
<span style="font-family: Times New Roman;">
</span><div class="MsoNormal" style="margin: 0in 0in 0pt; mso-layout-grid-align: none;">
<span style="font-family: "Segoe UI","sans-serif"; mso-fareast-font-family: Calibri; mso-fareast-theme-font: minor-latin;"><span style="mso-spacerun: yes;">
</span>controller.parmReportName(reportName.defaultDesign); <span style="mso-spacerun: yes;"> </span>// Make sure you specify the default design while
running the report and this is required to run the report and to get the dialog.<o:p></o:p></span></div>
<span style="font-family: Times New Roman;">
</span><div class="MsoNormal" style="margin: 0in 0in 0pt; mso-layout-grid-align: none;">
<span style="font-family: "Segoe UI","sans-serif"; mso-fareast-font-family: Calibri; mso-fareast-theme-font: minor-latin;"><span style="mso-spacerun: yes;">
</span>controller.parmArgs(_args);<o:p></o:p></span></div>
<span style="font-family: Times New Roman;">
</span><div class="MsoNormal" style="margin: 0in 0in 0pt; mso-layout-grid-align: none;">
<span style="font-family: "Segoe UI","sans-serif"; mso-fareast-font-family: Calibri; mso-fareast-theme-font: minor-latin;"><span style="mso-spacerun: yes;">
</span>controller.startOperation();<o:p></o:p></span></div>
<span style="font-family: Times New Roman;">
</span><div class="MsoNormal" style="margin: 0in 0in 0pt; mso-layout-grid-align: none;">
<span style="font-family: "Segoe UI","sans-serif"; mso-fareast-font-family: Calibri; mso-fareast-theme-font: minor-latin;">}</span></div>
<span style="font-family: "Segoe UI","sans-serif"; mso-fareast-font-family: Calibri; mso-fareast-theme-font: minor-latin;"><div class="MsoNormal" style="margin: 0in 0in 0pt; mso-layout-grid-align: none;">
</div>
<div class="MsoNormal" style="margin: 0in 0in 0pt; mso-layout-grid-align: none;">
<span style="font-family: "Segoe UI","sans-serif";">And
now, Create the output menu item and specify the object type to class and specify
the object to this controller class which we create now. And the report is ready
to select the design at runtime.<o:p></o:p></span></div>
<div class="MsoNormal" style="margin: 0in 0in 0pt; mso-layout-grid-align: none;">
<span style="font-family: Times New Roman;">
</span></div>
<div class="MsoNormal" style="margin: 0in 0in 0pt;">
<span style="font-family: "Segoe UI","sans-serif";">Hope
this will helps you,</span></div>
<div class="MsoNormal" style="margin: 0in 0in 0pt;">
<span style="font-family: "Segoe UI","sans-serif";">Prasan..
</span><span style="font-family: Wingdings; mso-ascii-font-family: "Segoe UI"; mso-bidi-font-family: "Segoe UI"; mso-char-type: symbol; mso-hansi-font-family: "Segoe UI"; mso-symbol-font-family: Wingdings;"><span style="mso-char-type: symbol; mso-symbol-font-family: Wingdings;">J</span></span><span style="font-family: "Segoe UI","sans-serif";"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin: 0in 0in 0pt; mso-layout-grid-align: none;">
<span style="font-family: Times New Roman;">
<o:p></o:p></span></div>
</span><div class="MsoNormal" style="margin: 0in 0in 0pt; mso-layout-grid-align: none;">
</div>
<span style="font-family: Times New Roman;">
</span></span></span></div>
Prasanhttp://www.blogger.com/profile/12994242712106741793noreply@blogger.com4tag:blogger.com,1999:blog-3099421127115759789.post-28595943493764606872013-04-09T14:52:00.002+05:302013-04-09T14:54:37.942+05:30AX 2012 - Technical best practices<div dir="ltr" style="text-align: left;" trbidi="on">
Hi,<br />
<br />
you cand find the top best practices for developement in AX 2012 here<br />
<br />
Please <a href="http://msdn.microsoft.com/en-us/library/aa658028.aspx" target="_blank">Click here</a><br />
<br />
Thanks,<br />
Prasan :)<br />
<br />
</div>
Prasanhttp://www.blogger.com/profile/12994242712106741793noreply@blogger.com0tag:blogger.com,1999:blog-3099421127115759789.post-30136356969117533212012-08-16T17:34:00.002+05:302012-08-16T17:34:29.434+05:30Convert/Upgrade MorphX Report to SSRS in Dynamics AX<div dir="ltr" style="text-align: left;" trbidi="on">
Hi,<br />
<br />
Convert/Upgrade MorphX Report to SSRS in Dynamics AX. Please follow the link<br />
<br />
<a href="http://dynamicspost.blogspot.com/2012/04/convertupgrade-morphx-report-to-ssrs-in.html">http://dynamicspost.blogspot.com/2012/04/convertupgrade-morphx-report-to-ssrs-in.html</a><br />
<br />
:)</div>
Prasanhttp://www.blogger.com/profile/12994242712106741793noreply@blogger.com0tag:blogger.com,1999:blog-3099421127115759789.post-79087544768584252362012-08-02T22:19:00.002+05:302012-08-02T22:19:50.666+05:30<div dir="ltr" style="text-align: left;" trbidi="on">
For some better AX links--<br />
<br />
<a href="http://twitter.com/dynamicserphub">http://twitter.com/dynamicserphub</a>
<br />
<br />
-Prasan :-)</div>Prasanhttp://www.blogger.com/profile/12994242712106741793noreply@blogger.com0tag:blogger.com,1999:blog-3099421127115759789.post-86313696841419411992012-07-13T18:43:00.002+05:302012-07-13T19:01:19.755+05:30AX2012- Error executing code: object does not have method construct<div dir="ltr" style="text-align: left;" trbidi="on">
HI,<br />
<br />
When working with AX 2012 outbound document service, I faced this issue.<br />
When I clicked the send electronically button on my custom created form, then the I could see the message is queued in queue manager form. On running of the batch I could see status as error with description "Error executing code: <empty class> object does not have method construct".<br />
<br />
Solution:<br />
<br />
<span style="text-align: -webkit-auto;"><span style="color: #666666; font-family: 'Trebuchet MS', Trebuchet, Verdana, sans-serif;"><span style="font-size: 13px; line-height: 18px;">You need to be few things to fix this error. the issue is due to compilation error where the particular method is not found while run time. So perform the following steps.</span></span></span><br />
<br />
<span style="color: #666666; font-family: 'Trebuchet MS', Trebuchet, Verdana, sans-serif; font-size: 13px; line-height: 18px; text-align: -webkit-auto;">First, compile all the objects pertaining to a AIF document service.</span><br />
<span style="color: #666666; font-family: 'Trebuchet MS', Trebuchet, Verdana, sans-serif; font-size: 13px; line-height: 18px; text-align: -webkit-auto;">Secondly, compile the base class - AxInternalBase</span><br />
<span style="color: #666666; font-family: 'Trebuchet MS', Trebuchet, Verdana, sans-serif; font-size: 13px; line-height: 18px; text-align: -webkit-auto;">At last, select your project node and "Generate incremental CIL".</span>
<br />
<span style="color: #666666; font-family: 'Trebuchet MS', Trebuchet, Verdana, sans-serif; font-size: 13px; line-height: 18px; text-align: -webkit-auto;"><br /></span><br />
<div style="text-align: -webkit-auto;">
<span style="color: #666666; font-family: 'Trebuchet MS', Trebuchet, Verdana, sans-serif;"><span style="font-size: 13px; line-height: 18px;">this will fix this error.</span></span></div>
<div style="text-align: -webkit-auto;">
<span style="color: #666666; font-family: 'Trebuchet MS', Trebuchet, Verdana, sans-serif;"><span style="font-size: 13px; line-height: 18px;"><br /></span></span></div>
<div style="text-align: -webkit-auto;">
<span style="color: #666666; font-family: 'Trebuchet MS', Trebuchet, Verdana, sans-serif;"><span style="font-size: 13px; line-height: 18px;">for more info refer this link: </span></span><a href="http://findax.blogspot.com/2012_03_01_archive.html#3739125515927189805">http://findax.blogspot.com/2012_03_01_archive.html#3739125515927189805</a></div>
<div style="text-align: -webkit-auto;">
<br /></div>
<div style="text-align: -webkit-auto;">
<br /></div>
<div style="text-align: -webkit-auto;">
Thanks,</div>
<div style="text-align: -webkit-auto;">
Prasan</div>
</div>Prasanhttp://www.blogger.com/profile/12994242712106741793noreply@blogger.com2tag:blogger.com,1999:blog-3099421127115759789.post-13020358099327585692012-07-10T23:11:00.002+05:302012-07-10T23:11:29.055+05:30Creating single field as Primary key in AX 2012<div dir="ltr" style="text-align: left;" trbidi="on">
Hi Everyone, Hope you all doing well. I have come with the steps of creating the single field as primary in AX 2012.<br />
<br />
1) Create the Table and add required fields to the table as you all knows.<br />
2) Create an Index by dragging the required field to the Index.<br />
3) Set the following Index properties:<br />
a) AllowDuplicates to "NO".<br />
b) Alternate key to "YES".<br />
4) Set the
PrimaryIndex property of the table to newly created index after creating the Index.<span style="background-color: white;"> </span><br />
<br />
All The Best... :)<br />
<br />
Please comment me your suggestions for my posts..</div>Prasanhttp://www.blogger.com/profile/12994242712106741793noreply@blogger.com2Dubai - United Arab Emirates25.271139 55.30748524.8116565 54.675771 25.7306215 55.939199tag:blogger.com,1999:blog-3099421127115759789.post-45726566164852434402012-02-26T13:11:00.001+05:302012-02-26T17:53:10.220+05:30Initialize the query in the report<div dir="ltr" style="text-align: left;" trbidi="on">We will assume the table as AssetTable( where the report is based on AssetTable), then write the code in init() method as<br />
public void init()<br />
{<br />
if(this.args().dataset() == TableNum(AssetTable))<br />
{<br />
AssetTable = this.args().record();<br />
}<br />
super();<br />
}<br />
<br />
Write the InitQuery() to initialize the query which is as follows..<br />
<br />
public Query initQuery(Query _query)<br />
{<br />
QueryBuildRange range;<br />
;<br />
query = _query;<br />
if (AssetTable)<br />
{<br />
range = query.dataSourceTable(tablenum(AssetTable)).findRange(fieldnum(AssetTable,AssetId));<br />
if (!range)<br />
range = query.dataSourceTable(tablenum(AssetTable)).addRange(fieldnum(AssetTable,AssetId));<br />
range.value(AssetTable.AssetId);<br />
<br />
or<br />
<br />
SysQuery::findOrCreateRange(query.dataSourceTable(tablenum(AssetTable)), fieldnum(AssetTable, Assetid)).value(queryvalue(AssetTable.AssetId));<br />
}<br />
return query;<br />
}<br />
<br />
Now fi you call this specified report from the form which is based on Asset Table, then the report will run for specific Asset number.<br />
<br />
// To avoid the usage data when called from Fixed Assets form(This will stop the usage data updates)<br />
public boolean mustLoadSaveQuery()<br />
{<br />
if (AssetTable)<br />
{<br />
return false;<br />
}<br />
else<br />
{<br />
return true;<br />
}<br />
}<br />
Thanks, and hope It will helps you.</div>Prasanhttp://www.blogger.com/profile/12994242712106741793noreply@blogger.com2