Thursday, March 15, 2012

AX 2009 - creating a job to update a database field

I created the job using a basic SQL query to pull a record and then a method attached to that table that just added a defined variable amount to a date.



But that only did one record…   apparently I forgot the loop.  That was easy, just add while to the beginning of the select statement.


//ATLAS, Joseph Anderson - 03/14/2012 - J0001
static void ATL_jbAdjustRouteOprToDate(Args _args)
{
    ProdRoute pr;
    int idx = 0;
    ;

    ttsBegin;

        while select forUpdate pr
            where pr.OprFinished==0
        {
            pr.ATL_AdjustOprToDate = pr.AdjustToDate();
            pr.doUpdate();
            idx++;
        }

    ttsCommit;

//    update_recordset pr
//    setting
//        ATL_AdjustOprToDate = pr.AdjustToDate()
//    where OprFinished == 0;

    info(strFmt("Number of records updated is %1.", idx));
}

Wednesday, March 14, 2012

AX 2009 - Adding a calculated field to a grid

The first time I did this, I over-complicated it.  I wasn’t sure how to write a complicated SQL query so I create a Query object, then a View object that saw that query, and then a data Method that pulled that “record” and a display Method that pushed the field to the grid.

Yeah, over-complicated.

Here is a cleaner way to do it.



On the primary table for the form, add a method that generates the value.





In the Design of the Form, add an appropriate field.

  In this case it was a Date field.




Set the DataSource to the table, and instead of assigning a DataField you assign the DataMethod to the method you wrote.




Unfortunately, a calculated field can’t be sorted by or filtered by, so I have to build it directly into the table (third time is a charm!)


sql int to time

I found this thread and thought it was worth repeating.  My email-to-blog had a link to the original posts, but apparently it didn't come through.

Original Post:  I have stored, as seconds, a duration in a table. I would like to use a SELECT statement to retrieve the contents of the column but display them as a time. For example:

45 = 0:00:45
241 = 0:04:01
575 = 0:09:35

and so on...
---
Answer:
declare @seconds int
set @seconds = 241
select convert(char(8), dateadd(second, @seconds, ''), 114)
---
Response:

Thanks for this.
  I took your example and turned it in to this which works:

SELECT CONVERT(char(8), DATEADD(second, Duration, ''), 114) AS Duration

Monday, November 7, 2011

friends from Rota, Spain

I don't use this very much, but I know that google indexes these pages since they own it.

I am looking for some friends from when I was in the military. Tim Darnell, Joel Cecil, Eric Wood, Michael David Sobanski (called Spaz), and Daniel Trachl.

Monday, May 18, 2009

Peter Bromberg's UnBlog: The Social API we really need.

(from Peter's blog - not first person)
 
Now here's the thing: I'm on Twitter; I like it because I can follow anybody I want, and although there is an awful lot of moronic "noise" (e.g., "I have a hangover and my cat just threw up"), there is also some interesting stuff that lets you find out where others in your particular "groove" are going, what they are working on, what they're thinking about. You can even post a request for help and occasionally somebody that's following you will give you a helpful idea.

The problem is, this is just a "teaser" of what it really could be, and it's totally disconnected from all the other "social" apps. It doesn't connect you to opening an IM chat (which is realtime, and often a lot more useful), there's no easy way to make it really integrate into a forum / messageboard (which is more permanent, and searchable), or del.ico.us (which helps with organizing and tagging resources that are shared with others), or a hybrid short url / spidering / social tagging site like my ittyurl.net, or a blog post with comments, or email notification of something I am following

http://petesbloggerama.blogspot.com/2008/05/social-api-we-really-need.html

 

FW: Synergy

Someone sent this to me and I am astounded at how well it works!!

 

Synergy lets you easily share a single mouse and keyboard between multiple computers with different operating systems, each with its own display, without special hardware. It's intended for users with multiple computers on their desk since each system uses its own monitor(s). Redirecting the mouse and keyboard is as simple as moving the mouse off the edge of your screen. Synergy also merges the clipboards of all the systems into one, allowing cut-and-paste between systems. Furthermore, it synchronizes screen savers so they all start and stop together and, if screen locking is enabled, only one screen requires a password to unlock them all. Synergy is open source and released under the GNU Public License (GPL).

 
Pros: Works very well (we have used it for months)

 

Cons: Poorly documented; can be difficult to get started

 

Freeware
Format: Software Size: 901 KB
Date: Jul 2007 Version: 1.3.1
License: Free
Platform: Windows
System Req: Windows 95/98/2000/ME/NT/XP