Tuesday, May 28, 2013

Windows Server 2012 - How to log someone out of server through RDS

Occasionally, you will need to drop other user's session(s) whether it is because of an issue with their log in instance, to free up User CAL licenses, or whatever. This is pretty easily accomplished but it can be tricky if you don't know where to look. Just follow the steps below.

This might seem like a stupid post for the technically inclined but you would be surprised at how many people don't know about this feature. It's especially helpful for the functional people who want to dip their toes in the tech realm.

Note: This used to be Terminal Services (TS) but it was re-branded Remote Desktop Services (RDS) for Windows Server 2008.

Do the following:
  1. Go to 'Start' 
  2. Go to 'Administrative Tools' -> 'Remote Desktop Services' -> 'Remote Desktop Services Manager' (Figure 1)
    1. You will see a list of users in this 
  3. Right click on the user you want to log off of the server and click on Log Off. (Figure 2)
    1. Note: The 'State' will indicate if they are 'Active' or Disconnected'. If a user didn't log off before closing their session, you might see them with 'Disconnected'. The 'Idle Time' field will also show you the number of minutes that have elapsed since the last keyboard or mouse input to a session.
  4.  Click on 'Ok' in the message that says 'The selected User(s) will be logged off' (Figure 3)
Figure 1 - Navigate to 'Remote Desktop Services Manager'

Figure 2 - Logging off a specific user

Figure 3 - The message given when the 'Log Off' feature is selected


Saturday, May 25, 2013

How to select record in table using ValidFrom and ValidTo ValidTimeState functionality that is NOT the current date/time (pull old history records)

AX out of the box will only allow the selection of a table record using the ValidTimeState function if the current date/time falls within the ValidFrom and ValidTo fields. It will ignore all the other records that match that criteria that fall outside of the current date/time as they are considered inactive or 'non-valid' times (either in the past/outdated/historical or won't take into effect until sometime in the future.

Sometimes you will need to query a previous record that used to be valid. To do this you can do the below.

Note: Remember that this feature allows the unique index of a table to exist for various time spans and not allowing any overlap. This was a new AX 2012 feature. 

The below code will ONLY return back the current active record based on the Valid Time State/Date for the current date/time.
select firstOnly omHierarchyRelationship
    where omHierarchyRelationship.HierarchyType == omHierarchyType.RecId
        && omHierarchyRelationship.ParentOrganization == omOperatingUnit.RecId;

This select below will NOT WORK to pull a record for a previous From/To date/time (historical non-active record).
select firstOnly omHierarchyRelationship
    where omHierarchyRelationship.HierarchyType == omHierarchyType.RecId
        && omHierarchyRelationship.ParentOrganization == omOperatingUnit.RecId;
        && omHierarchyRelationship.ValidFrom >= utcDatePassed;
        && omHierarchyRelationship.validTo <= utcDatePassed;

This select will WORK to pull a record from a previous From/To date/time (historical non-active record).
select firstOnly validTimeState(utcDatePassed) omHierarchyRelationship
    where omHierarchyRelationship.HierarchyType == omHierarchyType.RecId
        && omHierarchyRelationship.ParentOrganization == omOperatingUnit.RecId;

Special thanks to Joris de Gruyter for his post below. He nailed it in both select statements and a query. Please scope it out for more information.
Dynamics Ax Musings - Valid Time State/Date Effective Framework - Part2

Wednesday, May 22, 2013

Dynamics AX 'CacheAddMethod' functionality made easy

Took a lot of time off from programming and forgot how to do small things like cacheaddmethods. Not something I do all the time in the functional realm (duh!). All the posts around this I found online were all saying the same thing. This is my cheat sheet for this. New content on the web is never a bad thing.

This post will take the assumption that we are creating a new display method and referencing it to an existing form. So basically showing beginning to end stuff.

Note: Using cacheAddMethod for a field will not allow you to filter this field; it is display/informational only
Note: Using cacheAddMethod can cause the grid functionality to move slower so be cognizant of using this in excess.
  1. Create a display method on the table that is the datasource on the grid of interest (could be primary). For instance, if the grid in the form was showing sales line information, we are going to create a new method on the table (not the form or datasource; the table itself). It might look like the below in Figure 1. It can have whatever in it but it will need to return something. This will be the value you see in the grid
  2. Reference this display method on the form's datasource's init method after the super. See Figure 2 below. Notice the use of 'tableMethodStr'. The first parameter is the table that we added a method to in Step 1 and the second parameter is the display method name we created from Step 1.
  3. Add a field (of the correct data type) to the grid. Reference the correct datasource and put hte name of the table method added in Step 1. See Figure 3 below.
public display salesQty daxSalesQtyReferenced()
{
    return this.InventTransId ? this.invoicedInTotalServer() : 0;
}
Figure 1 - Display method on the table
void  init()
{
    ;

    super();

    salesLine_ds.cacheAddMethod(tableMethodStr(SalesLine, daxSalesQtyReferenced));
} 
Figure 2 - The display method in the datasource of the grid after the super call 

Figure 3 - Add a field to the grid and referenced the new cached method in the DataMethod field

A blog post about plagiarism and what people should know

I have quite the interesting post today. I'd advise people to read it in its entirety and think about it before 'referencing' articles on someone else's blog.

Background: I was severely plagiarized with many of my posts being posted word for word on another person's blog including pictures and my personal commentary, sometimes not even referencing anything 'DAX Dude' anywhere in it while still retaining the identifier 'I' in the sentences which would indicate they are original thoughts of the plagiarist's. None of them had links to the original or anything indicating that they were re-posting someone else's stuff. #ShakeHead

For people that know the real me, I'm pretty chill about helping people out. I look past company loyalties and differences in the effort to advance the community of a product I decide to focus a good portion of my career around. Obviously I know more than just the Dynamics and Microsoft software stack (as should all people who call themselves coders...) so I'm not tied life or death career-wise to the success a product.

I won't hound people or be rude if they're respectful and considerate if they want to reference things from my site and use proper citation or credit to the original work where due as everyone who has graduated 3rd grade has done. Unfortunately, some people made their way through school or created a career around stealing other people's work.

The point of my daxdude.blogspot.com blog is to enhance the AX community and knowledge of the product in the effort to help out customers get a better implementations. I have spent many years working on this site casually and anonymously so it doesn't really help my personal career at all. It started as something to help me keep my sanity on the road and has grown into something much bigger.

I won't lie and say I'm not bothered by people who exploit and blatantly plagiarize my site for personal gain. I am bothered. Very bothered. I want to say I don't take it personally but I do for some reason. Maybe its because this site isn't 'business' to me so much as a hobby and eats away at my personal time it takes to write a meaningful article that someone tries (or unintentionally tries) to pass off as their own.

There are many reasons people would intentionally steal someone else's intellectual property (IP). I am so bothered in fact, I am writing this blog do discuss this topic. I did some brush up research and will share my findings here. There were some blatant cases that came up in looking at who is trying to steal my stuff that I found that made me want to stop blogging all together out of sheer disappointment... Thanks to some kind words from some people in the AX community, I decided to keep going.
  1. What is plagiarism? 
  2. How does plagiarism hurt the content originator?
  3. Why would someone knowingly plagiarize a blog?
  4. Arguments against intentional plagiarism
  5. Is is possible someone accidentally committed plagiarism?
  6. How can I make sure I don't plagiarize a site?
  7. What can I do to prevent plagiarism?
  8. How can I handle people who I have identified as plagiarizing my material?
PART 1 - What is plagiarism? 

See below from  Dictionary.com: Plagiarism Definition 
"pla·gia·ris [pley-juh-riz-uhm, -jee-uh-riz-] Show IPA


noun
1.
an act or instance of using or closely imitating the language and thoughts of another author without authorization and the representation of that author's work as one's own, as by not crediting the original author: It is said that he plagiarized Thoreau's plagiarism of a line written by Montaigne. appropriation, infringement, piracy, counterfeiting; theft, borrowing, cribbing, passing off.
2.
a piece of writing or other work reflecting such unauthorized use or imitation: “These two manuscripts are clearly plagiarisms,” the editor said, tossing them angrily on the floor."

Here is some detailed information for the inquisitive folks in the crowd:Complete version of the U.S. Copyright Law, December 2011

Enjoy! The above should be enough information for you to NOT DO IT! If you do still, I'll happily bring it to your attention.

PART 2 - How does plagiarism hurt the content originator?
  • Steal original author's ideas and content by trying to pass them off as their own thus putting into doubt in the reader's mind who was the original creator of the content.
  • Get more traffic via search engines on certain issues that are in same niche as the originator's content
  • Take away advertising revenue from the originator(this does not factor into mine as I currently don't get ad sense revenue)
  • Contribute to the group mentality that plagiarizing is ok and make the issue exponentially worse
  • Not allow the author to amend content that needs to be for corrections or additions thus leaving outdated content out on the web
PART 3 - Why would someone knowingly plagiarize a blog?  
  • Someone who doesn't understand plagiarism or what constitutes it
  • Attempting to profit off your work by drawing more traffic for ad revenue
  • Can't come up with original content on their own
  • Laziness
  • Think they are not because they don't know how to properly cite information (and they think they did)
PART 4 - Arguments against intentional plagiarism

Argument 1: "I properly cited all copied content"
Odds are, no you didn't if someone is contacting you. If you did, no one should care. Also, you wouldn't worry as the person would have no case against you anyways

I don't care about being super technical but its good practice to preface a section by saying something about how the below was from XYZ from this website (provide actual link to original blog post) and is about [whatever]. Also, give a link to their twitter handle or something. This clearly lets people know that your site, however people got there, is primarily a vehicle to share an idea from someone else. I actually encourage this!

Additionally, PLEASE DON'T JUST COPY/PASTE EVERYTHING!!! Provide a summary or something and link back to the original so it encourages people to visit the original for more detailed steps on doing the process. You already got the page views on your site, help the person get page views who gave you those hits to begin with.

Or you can be super formal, too. Check out the below for formal ways to cite a blog post.
Martin Fenner Blog - How to formally cite a blog post
ScienceBlogs.com - How to cite a blog post properly

APAStyel.org - APA Style <- Great for generally accepted standards

Arguement 2: "The content is 'Fair use'."

This is a fun and easy one to win as it's usually brought up by those that don't know really what they're talking about. It's not always black or white but is a common talking point. Sometimes judgment needs to be used to determine this. Lets look at a very reliable source to pull together our own conclusions: http://www.copyright.gov/fls/fl102.html This is what your lawyer will google/bing for you at $200 an hour when I tell you I will contact my legal team if you don't remove my content from your site. Save a few bucks, read the below, and buy your significant other a nice dinner instead. See below from this link:

"Section 107 also sets out four factors to be considered in determining whether or not a particular use is fair.
  1. The purpose and character of the use, including whether such use is of commercial nature or is for nonprofit educational purposes
  2. The nature of the copyrighted work
  3. The amount and substantiality of the portion used in relation to the copyrighted work as a whole
  4. The effect of the use upon the potential market for, or value of, the copyrighted work"
PART 5 - Is it possible someone accidentally committed plagiarism?
It is possible for things to be accidental. In certain art forms (coding included), people learn from examples. That is why there are things like genres of music (punk, trip-hop, opera, baroque era, 80's electronic pop, etc) and art (impressionist, pop art, abstract, cubism, etc) but many musicians and painters define their personal style by making personal connections through others' original works. Check out the following from YouTube's Cellardoor1994: Similar Songs Part (1 of 2). It did a good job of showing similarities of songs for examples. Some are a stretch, others... not so much... Can you determine which were intentional?

When it comes to legal matters, its all about what can be proven. Take Bach writing techniques as an example, its easy to follow the formula/rules and pump out a song that might resemble another song unintentionally. Intent is very hard to prove and why lawyers make a lot of money protecting others' IP and personal property.

I'm not a lawyer but am an amateur hobbyist in the subject. I grew up with dreams of being a lawyer and thus read many text books about the subject. Won't go into details but by all means, steal my work on this blog and don't cite it. I'd love to share a scintillating conversation with you when I find you.

PART 6 -  How can I make sure I don't plagiarize a site? 
I've found this one to not be too hard if you follow common sense. Honest mistakes are forgivable as no one is perfect. Just correct them ASAP. The grey area for me becomes less grey when exact sentences start to line up or images are swiped that I created.

One area that is tricky is when I write about a subject I have read about in the past, I am unable to find the location where I originally found the information. If I take the ideas I remember to be mine and write about them even if they were remembered from somewhere else, is that plagiarism? Depends but probably not. I always try to differentiate between facts and opinions and do my best to be as original as possible with thoughts and ideas and credit as many people as possible along the way to establish credibility as well as further my own points.

PART 7 - What can I do to prevent plagiairism?
This was a fun one. I like to blog and wanted to keep doing it but realized some people will not respect your IP so its a necessity. I'm sure there are many ways to do the below but I've found the below to be most helpful going forward.

  1. Include watermarks on your images. Note, I have not done this for my 140+ blog posts but due to some highly unethical people, I now realize I must do this rather than focus on new content...
  2. Put verbal character in your blog posts so it identifies you as you. (People will relate to you more as well).
  3. Highlight a specific sentence you in your blog and paste it into the search of google/bing. It will flush out the criminals quite quick.
  4. Avoid plagiarizing content yourself. Karma...
  5. Visit sites like
  6. PlagSpotter (www.plagspotter.com). You can batch search your entire site on the net. Very helpful but does cost money. I have yet to find a batch searcher that is free.
PART 8 - How can I handle people who I have identified as plagiarizing my material?
There are lots of fun ways to do this. I've chosen to educate people and use examples to make sure people know they plagiarized my material. Honest mistakes, that's ok. Blatantly stealing posts? Nope.

Here are some ways to do this that I've come up with over dinner/drinks:
  1. Take screenshots of the violations for future reference. Make sure to show the URLs on both sites, a lot of content from both that would prove the offense, as well as the time of the file creation. Make sure this is on one screenshot so there is no disputing that they are one and the same.
  2. Contact the person directly and ask the offending posts to be taken down. Give a short time frame
  3. Report to the site that is hosting the blog to take it down. Reference both sites. 
  4. Report the violation to any advertising companies that are on their site as it can be a violation of their terms to steal content in an effort to generate more revenue fraudulently.
  5. Comment on the offending post indicating its in violation of plagiarism and must be taken down. Reference the actual post for visitors to go to.
  6. If the situation warrants, bring a legal team down on them.
  7. Post a blog post to your site making a case for their plagiarism. This will get fun if they have something that automatically posts content from your site to their blogs.
  8. Take to social media to discredit their blogs referencing point 7 above. 
--------------------------------------------------------------------------------------------------------------------------
In summation, please be respectful of content on my blog. It's not that much to ask.

Sunday, May 19, 2013

C# Error: 'Too many characters in character literal'

In coding a Windows 8 application, I was receiving the error 'Too many characters in character literal'.  Not sure why this was occuring. In my defense, with X++, you can use either even though double quotes should always be used for text that is not defined in a macro.

Solution: The issue is because single quotes were used in the string text. They should be double quotes. Single quotes should only be used for single characters only whereas double quotes should be used for more than one character.

Correct: "testemail@gmail.com"   Incorrect: 'testemail@gmail.com'


Thursday, May 16, 2013

AX 2012 AIF - How to create outbound AIF record through X++

When you want to create a record in the outbound AIF queue in AX 2012, you can use the below code to accomplish this.  It can be included in inserts, updates, on a button, etc. Doesn't really matter.

There are two variables below:
  • YYYTable - This should be the instance record of a table. For example, if you create a new vendor, customer purchase order, etc, you can put the record instance in this spot (for instance, in the insert override, after the super() you can use 'this').
  • YYYService - The name of the service that is being use
In order for this to work, you will need to setup an outbound port and run the AIF process with the for various processes. Until this last process is complete, this record will remain in the AIF queue.

AxdSendContext      axdSendContext      = AxdSendContext::construct();
AifEntityKey        aifEntityKey        = AifEntityKey::construct();
Map                 keyData;
AifConstraintList   aifConstraintList   = new AifConstraintList();
AifConstraint       aifConstraint       = new AifConstraint();

// Select key data
keyData = SysDictTable::getKeyData(YYYTable); // 'this' is the internal instance of ZZZTestAIF so we can use this
aifEntityKey.parmKeyDataMap(keyData);

// Select context as original
axdSendContext.parmXMLDocPurpose(XMLDocPurpose::Original);
axdSendContext.parmSecurity(false);

// No constraints
aifConstraint.parmType(AifConstraintType::NoConstraint) ;
aifConstraintList.addConstraint(aifConstraint) ;

// Initiate AIF Portal vendor service
AifSendService::submitDefault(classnum(YYYService), // Assign the service here
                              aifEntityKey,
                              aifConstraintList,
                              AifSendMode::Sync,
                              axdSendContext.pack());

Sunday, May 12, 2013

Manually process inbound and outbound AIF interfaces instead of using batch job

If you want to process inbound and outbound manually instead of setting up the batch job, you can copy and past the code below and click run to process everything. This has been used quite a bit by me and in several versions of AX so you should be good to go.

// Run this to manually process the AIF messages
static void DAXProcessAIF(Args _args)
{
    // Inbound
    new AifGateWayReceiveService().run();       // read the messages
    new AifInboundProcessingService().run();    // process the messages in queue

    // Outbound
    new AifOutboundProcessingService().run();   // process messages in queue
    new AifGateWaySendService().run();          // send messages
}

Wednesday, May 8, 2013

AX 2012 - Report break down of user licenses used (i.e. Enterprise User CAL, Functional Users, etc)


The report is called 'Named User License Counts' (see picture below with parameters).         

I’m not aware of a front end entry point into this report. I also traversed the AOT looking for where it is front facing and I came up with nothing.

You can access it from the backed by going into the AOT\Menu Items\Output\SysUserLicenseCountReport. You then right click on this object and select ‘Open’. This will run the report.

This report is helpful when evaluating how many user licenses a company is actually using. Usually used when a company asks 'How are we doing on our licenses?' or 'Do we really need all these licenses we're paying for?'. This report excludes device CALs which are used for the AX for Retail licensing. You'll have to evaluate those differently.

It reports off the SysUserLicenseCount table based on the date that you entered in the report parameter. Remember that in AX 2012 the licenses are NAMED USERS not concurrent users like previous versions.

The report will provide totals for the user counts as well as:
  •  the user license type (self serve user, task user, functional user, enterprise user)
  • the license count (how many AX users can potentially use the system in a given period)
  • the actual count (how many AX user licenses are currently being used)
An example of this report in action would be to look at a type of license (e.g. Functional User) and determining that only 50 licenses are being used but you have purchased 200. You might be able to scale this down depending on why the 200 users were initally determined as necessary. You would want to investigate but this report gave you a hard measurement as to what is needed over a period of time.

Figure 1- The report when it is printed. I cut it off a the bottom as it looked even more stupid than the one above being redacted that much. 


Figure 2 - The SysUserLicenseCount table used as the backbone of the report above


Sunday, May 5, 2013

Error running Windows 8 tutorial app

Unfortunately, I had some hard drive issues that left me without data but still with a working hard drive. Long story... but I decided to reinstall with Windows 8 on base. I would always recommend doing a clean install and not an upgrade when it comes to OS'es or base applications. I really hate to say that I don't trust Microsoft to not think of all situations in an upgrade scenario but no one is perfect. Anyways... I went with a clean Windows 8 install using Windows 8 upgrade (PLUG: http://pcsupport.about.com/od/windows-8/a/clean-install-windows-8-upgrade.htm) and installed VS2012 while I was at it.

Upon attempting to run the Windows 8 tutorial app 'TwitterRT', I hit the following error: 'The project [PROJECT] cannot be started directly. In order to debug this project, you must consume it from a Windows Store app project that creates a package and is marked as the Startup Project.'

INTERESTING NOTE: This error used to read: '... you must consume it from a Metro style app project that creates a package and...'. Microsoft no longer uses the term 'Metro style' to refer to its new UI due to the German retailer Metro AG's branding of Hardware, Software, and Storage media. Since I cannot respond to the statement: 'Sprechen sie deutsche', I have to take people's word for it that they are a large company and had enough weight to throw around for Microsoft to do a last minute mambo with their W8 UI branding.

I was able to see the components in the project but not able to see the full working application. The weird part for me is that I got this sample from Samples>Visual C#>Windows Store apps>XAML>Twitter, the extension .vcxproj is a Visual C++ Project. This was also weird because the description of the app was 'My goal is to make tweeting from a C# Metro application as easy as possible. To that end, I created a little app called TwitterRt.'. So this app is clearly a C# app that is throwing a C++ error... why???

Anyone have a solution to this? I don't but I'm blogging about it anyways. Definition: blog (n) - A Web site on which an individual or group of users record opinions, information, etc. on a regular basis.

Friday, May 3, 2013

Windows Phone SDK 8.0 Warning: 'This computer does not support hardware virtualization'

Note: This post was from June of 2012. It is still relevant so I'm posting it.
 
When installing the Windows Phone SDK 8.0, I encountered a warning 'This computer does not support hardware virtualization, which means Windows Phone Emulator 8.0 can't run on this PC.'  I was installing the Windows Phone SDK 8.0 on a clean Windows 8 Enterprise 64-bit virtual machine.

This error was occurring because the Windows Phone Emulator 8.0 was not designed to run within a virtual machine.

I attempted to find a solution to this. There was some stuff about changing things in the BIOS which I tried to fix but never was able to. It always resulted in the statement from people that 'Cannot virtualize hardware in a virtualized environment'. I still think there has to be a solution for this but I haven't done virtualization stuff since VMWare's ESX 3.0. If you know of something, share it below. I'm open to learn. This is more of a learning post than anything.