Gofirstrecord And Configuration Screens In Acumatica

GoFirstRecord and Configuration screens in Acumatica

Hello everybody,

today I want to share with you one of my mistakes. 

Few days ago I started to develop Configuration screen, or screen which should end at xx101000. After I completed it and passed for testing I faced a challenge. The page should display only the first record. So I implemented some logic which selected the first record. After that I re-read one of the manuals and found that DataSet have property PageLoadBehavior which can be set to GoFirstRecord!!!!

After I removed my code which loaded first record, and added beforementioned property my configuration screen behaved as really configuration screeen. 

No Comments

Add a Comment

Saving Complex Objects In Acumatica

Saving complex objects in Acumatica

Hello everybody,

today I want to share one nesessary step which is needed for graph in order to save graph which has more then one DAC ( data access class ).

In my case I have DAC PRPayRoll, which is joined with classes PRPayrollDetails, PRPaySlip, PRTran.

In that case it is needed to mention in graph declaration primary dac.

So instead of writing 

public class PayRollManager : PXGraph<PayRollManager>
I wrote
public class PayRollManager : PXGraph<PayRollManager, PRPayroll>

Where PRPayroll is primary DAC. Or if to quote Acumatica manual PRPayroll is primary DAC for business logic container

4 Comments

  • Gabriel Michaud said

    Just curious - are you working on a payroll system for Acumatica?

  • Gabriel Michaud said

    For which country? Are you aware of the work being done right now by PCB? Can you e-mail me to discuss? I'm curious to hear about your project.

    Gabriel Michaud
    Director of Product Management
    Acumatica

  • docotor said

    I'm from Ukraine, Kyiv. I'm not aware about PCB. Just wrote you e-mail.

Add a Comment

Undefined Cannot Read Property Length Of Undefined

Undefined: Cannot read property "length" of undefined

Hello everybody.

Today I want to share how to deal with Acumatica error message

undefined: Cannot read property "length" of undefined.

If you face it, you need to know that some members of your DAC need attribute either PXInt or PXDbInt or something similar. 

One more detail, DAC should have at least one IsKey = true property

No Comments

Add a Comment

Failed To Subscribe Event Cacheattached In Graph

Failed to subscribe event CacheAttached in graph

Hello everybody, who follows my blog.

Today I want to share with you some surpsise of Acumatica which taken me some time. 

In one of my graphs I added CacheAttached event in order to modify way of displaying title. As outcome I got something like this:

Failed to subscribe event Graph::Table_Row_CacheAttached in graph Graph. 
Method signature looks like event handler, 
but cache Table has not been found in the list of auto initialized caches.
Remove unused event handlers from code.

Let's assume that Table name is BAccount. 

It is possible to solve with the following statement:

[PXHidden]
public PXSelect<BAccount> HiddenBacount;

The following statement added BAccount into list of auto initalized caches and solved my problem.

2 Comments

  • Fabio said

    Hi.
    Today I had similar problems, and thanks to your site I solved issue

  • docotor said

    PXHidden does the following: hides the data access class (DAC), the business logic controller (graph), or the view from the selectors of DACs and graphs and from the Web Service API clients.

Add a Comment

11 Lessons You Will Never Learn In School

11 lessons you will never learn in School

Hello Everybody,

I want to share what I found here some ideas:

RULE 1: Life’s not fair. Get used to it

You could be the smartest, hardest working most noble person alive and still not get that A. Or promotion. Or the girl, whatever floats your boat. The sooner you stop expecting life to hand you the things you think you “deserve”, the easier it will be to bounce back in those times when life knocks you down and just keeps kicking. You could earn your way to that promotion and still have it snatched from under you – get over it. That doesn’t mean sit back and take it. It means that you need to learn from those ugly situations and better position yourself to reap the benefits of your diligence.

RULE 2: The World Doesn’t care about your self esteem

“The world expects you to accomplish something BEFORE you feel good about yourself” … so get on it. Start making something of yourself today. Right now. That idea you’ve been pushing to the back of your mind might be just the thing to propel you to the limelight, so get on it. You only truly fail if you never try.

RULE 3: You will not make six figure salary right after school

“You won’t be a vice president with a car phone until you earn both.” This addresses the entitled behavior that young people display on a daily basis. It’s not a good look for anyone to act like the world should unfurl a red carpet at their feet just because they showed up. You have to work hard for what you get – I’m talking sweat and blood here, and don’t expect anyone’s gratitude for it.

RULE 4: If you think your teacher is tough, wait till you meet your boss

All those deadlines you think are unreasonable at best, those times she locked you out of class because you showed up late? Ten times worse with a boss. Only, instead of chewing you out infront of a classroom, it’s a whole office. Teachers are legally mandated to show some restraint, bosses aren’t. He’ll call you all sorts of names your teacher only dreams of saying to your face, then show you the way to the unemployment line. This isn’t to scare you off of gainful employment, just to encourage you to practice dealing with difficult authority figures, to better prepare you for the future, so you can avoid an emotional outburst at the office.

RULE 5: Flipping buggers is not beneath your dignity

“Your grandparents had a different word for burger flipping – they called it OPPORTUNITY.” So get over yourself and take that job that you think is beneath you. A waiter/waitress position opens up at your favorite restaurant? Swallow your pride and take it. Use that as a stepping stone. The richest men in the world started off as paper boys – remember that.

RULE 6: If you mess up, it’s not your parents fault

“So don’t whine about your mistake – learn from them.” Too many people fall into the trap of claiming “mommy” and “daddy” issues when they mess up. According to Bill Gates, you need to stop spreading the blame around and take responsibility for your failures. Only then do you earn the right to own your successes as well.

RULE 7: Your folks know something you don’t know     

“Before you were born, your parents weren’t as boring as they are now. They got that way from paying your bills, cleaning your clothes and listening to you talk about how cool you think you are. So before you save the rainforests from the parasites of your parents’ generation, try delousing the closet in your own room.” Self-explanatory.

RULE 8: Your school may have done away with winners and losers, but life has not

“In some schools, they have abolished failing grades and they’ll give you as many tries as you want to get the right answer. This doesn’t bear the slightest resemblance to ANYTHING in real life.” Only the strong survive. This doesn’t mean that it’s okay to do whatever it takes to come out ahead – the end does not justify the means. It just means that you need to keep the big picture in mind – to remember that while it’s okay to do your best, it’s better to always ensure that you go the extra mile to prove yourself.

RULE 9: Life is not divided into semesters

“You don’t get summer off and very few employers are interested in helping you “find yourself”. Do that on your own time.” This is one thing most students don’t realize. The real world won’t give you time off to recoup your strength. Once life starts it just goes on and on, and on. The sooner you shift your way of thinking from seeing your holiday as time off, but as time to be spent making something worthwhile of yourself, the easier the transition to real life will be.

RULE 10: Television is not real life

“In real life, people actually have to leave the coffee shop and go to jobs.” This applies to more than just an episode of friends. Life seems a lot easier on TV than it is in real life. Sounds like common sense, but you’d be surprised at how many people expect to sleep in every morning and still be able to afford that dream holiday.

RULE 11: Be Nice to Nerds

“Chances are you’ll end up working for one.” Laugh all you want, but he showed that this is a very real possibility. That book worm you keep picking on for choosing the library over a twerk session could end up being your boss in the future, so be nice.

I like those statements.

2 Comments

  • Tim Rodman said

    These are great quotes. I'm very concerned for my generation, especially in the United States. We are a bunch of spoiled kids. I hope we won't need another Great Depression or World War to learn these lessons.

  • docotor said

    I don't know much about USA, but I can say that in Ukraine I also see enough spoiled children. And sadly not only children

Add a Comment

Rename Created Grid Column In Acumatica For Specific Graph Only

Rename created grid column in Acumatica for specific graph only

Hello everybody,

today I want to share trick about renaming item in grid. Suppose you want to use developed by Acumatica data access class of acumatica, which has name BAccount, and you have huge desire to rename it in column from "Account name" to "Employee Name".

You can use for such purpose CacheAttached event. In my case following code helped to achieve renaming:

        [PXDBString(60, IsUnicode = true)]
        [PXDefault()]
        [PXUIField(DisplayName = "Employee Name", Visibility = PXUIVisibility.SelectorVisible)]
        [PXFieldDescription]
        [PXMassMergableField]
        protected virtual void BAccount_AcctName_CacheAttached(PXCache sender)
        {
        }

No Comments

Add a Comment

Mql4 Round Numbers Indicator

MQL4 round numbers Indicator

Hello everybody,

Today I want to share with you another area. I had small order for MQL4 indicator for round numbers for Metatrader4 or as it is named MT4. The task was to draw lines at screen with some step at any currency pair. In order to implement it I started first of all Googling. Then I found almost implemented indicator at forexfactory just without option for modification steps. After wondering about code purpose of variables I created the following code:

//**************************************************
//*  RoundNr.mq4 (No Copyright)                    *
//*                                                *
//*  Draws horizontal lines at round price levels  *
//*                                                *
//*  Written by: Totoro @ forexfactory.com         *
//*  Modified by Yuriy Zaletskyy                   *
//**************************************************
#property indicator_chart_window
extern double LineSpace     = 1; // 1 unit = 0.01 of basic value (e.g. 1 USD cent)
extern color  LineColor     = Turquoise;
extern int    LineStyle     = 2;
extern string LineStyleInfo = "0=Solid,1=Dash,2=Dot,3=DashDot,4=DashDotDot";
extern string LineText      = "RoundNr ";
extern double stepSize = 0.1;
extern string stepSizeComment = "step size for jpy = 0.1, for others 0.001";
extern int digitsAfterComma = 2;
extern string digitsAfterCommaComment = "2 for jpy and 3 for non jpy pair";

double LineSpaceOld;
double HighScreen;
double Tief;
bool   FirstRun = true;

int deinit()
{
   double AbSpace = stepSize*LineSpace;
   double HigherScreen    = MathRound(110*HighScreen)/100;
   double LowerScreen   = MathRound(80*Tief)/100;
   for(double i=0; i<=HigherScreen; i+=AbSpace)
   {
      if(i<LowerScreen) { continue; }
      ObjectDelete(LineText+DoubleToStr(i,digitsAfterComma));
   }
   return(0);
}

int start()
{
   if(FirstRun)
   {
      HighScreen = NormalizeDouble( High[iHighest(NULL,0,MODE_HIGH,Bars-1,0)], digitsAfterComma );
      Tief = NormalizeDouble( Low[iLowest(NULL,0,MODE_LOW,Bars-1,0)], digitsAfterComma );
      FirstRun = false;
   }
   else if(LineSpace != LineSpaceOld)
   {
      deinit();
      HighScreen = NormalizeDouble( High[iHighest(NULL,0,MODE_HIGH,Bars-1,0)], digitsAfterComma );
      Tief = NormalizeDouble( Low[iLowest(NULL,0,MODE_LOW,Bars-1,0)], digitsAfterComma );
   }
   DrawLines();
   LineSpaceOld = LineSpace;
   return(0);
}

void DrawLines()
{
   double AbSpace = stepSize*LineSpace;
   double HigherScreen    = MathRound(110*HighScreen)/100;
   double LowerScreen   = MathRound(80*Tief)/100;

   for(double i=0; i<=HigherScreen; i+=AbSpace)
   {
      if(i<LowerScreen) { continue; }
      string StringNr = DoubleToStr(i,digitsAfterComma); // digits number in object name
if (ObjectFind(LineText+StringNr) != 0) // HLine not in main chartwindow { ObjectCreate(LineText+StringNr, OBJ_HLINE, 0, 0, i); ObjectSet(LineText+StringNr, OBJPROP_STYLE, LineStyle); ObjectSet(LineText+StringNr, OBJPROP_COLOR, LineColor); } else // Adjustments { ObjectSet(LineText+StringNr, OBJPROP_PRICE1, i); ObjectSet(LineText+StringNr, OBJPROP_STYLE, LineStyle); ObjectSet(LineText+StringNr, OBJPROP_COLOR, LineColor); } } WindowRedraw(); }

Enjoy.

Sql Formatting Tool

SQL Formatting tool

Few days ago I faced following challenge. SQL profiler gave me ugly SQL, which was unreadable for my eyes.

For example like this:

exec sp_executesql N'SELECT APAddress.AddressID, APAddress.VendorID, APAddress.VendorAddressID, APAddress.IsDefaultAddress, APAddress.RevisionID, APAddress.AddressLine1, APAddress.AddressLine2, APAddress.AddressLine3, APAddress.City, APAddress.CountryID, APAddress.State, APAddress.PostalCode, APAddress.IsValidated, APAddress.tstamp, APAddress.CreatedByID, APAddress.CreatedByScreenID, APAddress.CreatedDateTime, APAddress.LastModifiedByID, APAddress.LastModifiedByScreenID, APAddress.LastModifiedDateTime FROM APAddress APAddress WHERE (APAddress.CompanyID = 2) AND  ( APAddress.AddressID = @P0) ORDER BY APAddress.AddressID /* admin@AP.30.40.00 */',N'@P0 int',@P0=-2147483647

If you can read it, congratulations, you are genius and I'm envy of you so you can stop reading further. But if you are just programmer as me, then the next step is the following:

1. remove exec sp_executesql 

2. In some editor find and replace @P0 with value -2147483647

3. remove tail /* admin@AP.30.40.00 */',N'@P0 int',@P0=-2147483647

4. Navigate in your browser to http://www.dpriver.com/pp/sqlformat.htm

5. Copy/Paste in window and choose format mssql

6. Press format SQL.

Compare previous sql with the following:

SELECT apaddress.addressid,
       apaddress.vendorid,
       apaddress.vendoraddressid,
       apaddress.isdefaultaddress,
       apaddress.revisionid,
       apaddress.addressline1,
       apaddress.addressline2,
       apaddress.addressline3,
       apaddress.city,
       apaddress.countryid,
       apaddress.state,
       apaddress.postalcode,
       apaddress.isvalidated,
       apaddress.tstamp,
       apaddress.createdbyid,
       apaddress.createdbyscreenid,
       apaddress.createddatetime,
       apaddress.lastmodifiedbyid,
       apaddress.lastmodifiedbyscreenid,
       apaddress.lastmodifieddatetime
FROM   apaddress APAddress
WHERE  ( apaddress.companyid = 2 )
       AND ( apaddress.addressid = -2147483647 )
ORDER  BY apaddress.addressid 

IMHO the second option is easier to read.

4 Comments

  • Tim Rodman said 

    Nice tip. I didn't know about that website.

    I use the SQL Prompt plug-in from Red Gate which installs as a menu in SQL Management Studio. You can also format SQL using this tool.

  • docotor said

    Nice tool. IMHO even better then web site. But according to http://www.red-gate.com/products/sql-development/sql-prompt/

    "SQL Prompt starts at $369 per user" For now I'm not ready to pay to redgate such amount

  • Tim Rodman said

    I agree, it's a little pricey, especially if you can't get your company to pay for it.

    It does save time when writing code because it auto-completes columns, tables, even table joins for you. But, if you're just looking for a formatting tool, the website works great.

  • anonymous said 

    Freeware:
    Notepad++ has an add-in called "Poor Man's Sql Formatter"

    http://www.architectshack.com/PoorMansTSqlFormatter.ashx

Acumatica Customization Without Acumatica GUI

 

Hello.

Today I want to share some information about Acumatica customization.

Suppose, you want to change your pages not via Acumatica UI, but via Visual Studio. Reasons why you can have such desire can be the following:

1. Visual Studio is faster then Acumatica UI

2. You can put your changes under source control

3. You can easily exchange changes with your co-workers

Let's say you have following situation.

1. You need to make changes to pages ar301000.aspx and  pm301000.aspx and pm304000.aspx.

2. You need to add new page AP508000.aspx.

3. You want to include dll, which is named DS.dll.

In order to do this you'll need the following.

1. Create in your Acumatica instance folder CstPublished

2. Inside created folder create folders pages_ar, pages_pm

3. Copy/Paste into folder pages_ar page ar301000.aspx and into pages_pm pages  pm301000.aspx and pm304000.aspx.

4. Create new page AP508000.aspx in folder AP

5. Build your dll file

6. Create following file: project.xml, with the following records:

<Customization level="0" description="">
    <File AppRelativePath="CstPublished\pages_ar\ar301000.aspx" FileID="0849bd3b-c4ce-473e-8c82-c567112aa96b" />
    <File AppRelativePath="CstPublished\pages_ar\ar301000.aspx.cs" FileID="302c4089-6046-4a17-8411-1023315f5535" />
    <File AppRelativePath="Pages\AP\AP508000.aspx" FileID="b9e88968-7f36-4cfc-9383-caed8363c269" />
    <File AppRelativePath="Pages\AP\AP508000.aspx.cs" FileID="a1ce1918-f569-4ced-8a03-b5571dc26abb" />
    <File AppRelativePath="CstPublished\pages_pm\pm301000.aspx" FileID="8c174bf0-3143-4a86-83e9-c82704c9297a" />
    <File AppRelativePath="CstPublished\pages_pm\pm301000.aspx.cs" FileID="c435350a-89dc-455c-a9cb-6356987b2889" />
    <File AppRelativePath="CstPublished\pages_pm\pm304000.aspx" FileID="65b4f056-859f-463c-99cc-32a9cde11c7d" />
    <File AppRelativePath="CstPublished\pages_pm\pm304000.aspx.cs" FileID="46b0d39b-ba12-486a-be7f-6058a37cdca1" />
</Customization>

7. Create folder with the following structure:

   7.1 Folder CstPublished which has inside of it folders pages_ar and pages_pm. And pages_ar has all ar files, and pages_pm has changes related to pm pages

   7.2 Folder Pages, which has inside of it folder AP, and AP inside of it has AP508000.aspx and AP508000.aspx.cs files

   7.3 Put into folder file project.xml

8. Zip it and your deployment is ready.

Some pitfalls which I faced.

1. xml file should be named project.xml

2. FileId is guid, and each FileID should be unique.

3. All file and folder names shouldn't be capital. Not Pages_pm but pages_pm. And not CstPublished\pages_pm\PM304000.aspx but CstPublished\pages_pm\pm304000.aspx 

4. If you find other surprises with customization let me know.

 

11 Comments

  • mazia said 

    Hi
    Do you provide development support to partners?

  • docotor said 

    Hello Mazia,
    for free to some degree yes. And for money definitely yes :)

  • Tony said 

    Hi, I got some questions:

    1) Is there something else to do after adding the file project.xml (I zip it as you said in the /CstPublished folder with the name project.zip)? is this correct or it should go in a sub folder?

    2) The .dll also goes in /CstPublished or in a especific subfolder?

    3) I got embed SQL querys in the project.xml, It will be executed doing this? o I'll have to run in appart.

    The thing is that I added both files "project.xml" and the zipped "project.zip" and in the menu is not showing the pages menu (sitemap), I wonder if it's needed some kind of refresh to get the changes.

    I'm working with Acumatica version 4.20.0935

    Thanks for your help,
    Regards.

  • docotor said 

    Hello Tony,
    Inside the folder for customization following structure should be:
    Three folders: a) "Bin", b) "CstPublished", c) "Pages" and file project.xml.
    1. If you putted file project.xml into CstPublished folder, then move it one folder higher in the hierarchy.
    2. The .dll file goes to folder bin.
    3. It's possible to embed sql into customization, but I personally use two different files ( I mean customization file and project.sql which has all db changes )

  • docotor said

    I attached screenshot of my customization. Let me know if you'll need something else

  • Tony said 

    Hi again, and thanks for your reply It was very helpful. I had issues inserting the dll but I didnt notice that in the project.xml example was missing (I thought It was there xD).

    I have another question, those GUID for the FileID how are obtained? I'm working with powershell and I can't see a way to get those GUID corresponding for each file.

    Thanks...

  • docotor said 

    It can be any new guid, which is not mentioned in project. I used http://createguid.com web site. In case of powershell I can propose either to read from mentioned web site, or as another option to make some simple program which will generate for you guids

  • Fernando said 

    Hi Docotor!

    I have a question somehow related to this thread.
    Is it possible to include a ZIP file in the Projet.xml and then extract its content? Let me explain further:

    <File AppRelativePath="(...)\files.ZIP" FileID="0849bd3b-c4ce-473e-8c82-c567112aa96b" />

    We are facing difficulties in terms of time and path length while publishing our customization projects, so we thought that if we could just copy the ZIP file and then execute a command that would extract its content, then we could solve both problems at once. Is this feasible?

    Thanks for your help :)

  • docotor said 

    I don't think that it's possible. Actually I don't know. I just can propose you workaround. In your destination Acumatica instance locate folder CstPublished, and inside of it put your modified pages. Then you'll not need to include modified aspx pages into zip file. Just keep in mind naming conventions. In CstPublished should be ar301000 not AR301000. As far as I know Acumatica engine will make analysis of this folder and will consider them as active. If to speak about your pages which you made completely by yourself you can put them into Acumatica directory straight away. I also assume that you can put in Bin folder compiled version of your dll.

  • Ronan Masangcay said 

    I need to code on my local machine using Visual Studio (VS) VS2013 but will deploy the DLL on another machine that has an Acumatica ERP instance. Can I code in VS2013 in my PC and see the Acumatica objects (particularly, Data Providers) in my VS2013; my PC has Acumatica Framework already.

    Please let me know how

    TY

  • docotor said 

    You can code locally on your VS2013 and then you'll need to put dll and pages into Acumatica customization and then publish it at your Acumatica instance.

 

Get all columns of specific table

Tuesday, April 29, 2014 6:09:00 PM

Today I needed to get all columns of specifict table. 

SQL which you can use for this purpose is the following:

SELECT COLUMN_NAME 'All_Columns' FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME='Specific table'