Autonumbering In Acumatica Second Way

 

In one of my previous posts I described how to add autonumbering to acumatica. Described method will work pretty well, if you don't have any pop-ups which also need to have autonumbering. In case if you have such pop-ups, then it is different story.

My next assignment on the job was to add autonumbering to the screen "Fund Transfers" which is marked as "CA301000" to the field Document ref at three places:

There is a saying, that one image is better then thousands of words :).

Here is example of my code for OutExtRefNbr:

        protected void CATransfer_OutExtRefNbr_FieldDefaulting(PXCache sender, PXFieldDefaultingEventArgs e)
        {
            var row = e.Row as CATransfer;
            if (row == null)
                return;
            var refNbr = "001224";
            e.NewValue = refNbr;
        }

 

If you have a question why on earth code below needed:

                   var row = e.Row as "Class for which we will provide extension";

                   if( row == null )

                      return;

the answer is simple: because Acumatica for some unknown reason calls method FieldDefaulting and for mysterious reason passes into e.Row null. If you have any idea why, you are welcome to share them. I don't have and just used workaround ( don't say it to my boss ).

 

The second part of my task was to add some value to pop-up window. That can be done via the following template:

public class "Class Extention name" : PXGraphExtension<"Class for which we will provide extension">

{

      protected void "Class for which we will provide extension"_RowUpdated(PXCache sender, PXRowUpdatedEventArgs e)

      {

             Base.AddFilter.Current."Field in pop-up" = "some default value";

            Base.AddFilter.Update(Base.AddFilter.Current);

       }

"Field in pop-up" you can find also in Design mode of Acumatica forms.

Here is fragment of my source code for changes:

protected void CATransfer_RowUpdated(PXCache sender, PXRowUpdatedEventArgs e)
{
     Base.AddFilter.Current.ExtRefNbr = "0012224";
     Base.AddFilter.Update(Base.AddFilter.Current);
}

In case if you have any comments, ideas don't hesitate to share them via comments line.

There is a saying, that one image is better then thousands of words :).

Here is example of my code for OutExtRefNbr:

        protected void CATransfer_OutExtRefNbr_FieldDefaulting(PXCache sender, PXFieldDefaultingEventArgs e)
        {
            var row = e.Row as CATransfer;
            if (row == null)
                return;
            var refNbr = "001224";
            e.NewValue = refNbr;
        }

 

If you have a question why on earth code below needed:

                   var row = e.Row as "Class for which we will provide extension";

                   if( row == null )

                      return;

the answer is simple: because Acumatica for some unknown reason calls method FieldDefaulting and for mysterious reason passes into e.Row null. If you have any idea why, you are welcome to share them. I don't have and just used workaround ( don't say it to my boss ).

 

The second part of my task was to add some value to pop-up window. That can be done via the following template:

public class "Class Extention name" : PXGraphExtension<"Class for which we will provide extension">

{

protected void "Class for which we will provide extension"_RowUpdated(PXCache sender, PXRowUpdatedEventArgs e)
{
      Base.AddFilter.Current."Field in pop-up" = "some default value";
      Base.AddFilter.Update(Base.AddFilter.Current);
}

"Field in pop-up" you can find also in Design mode of Acumatica forms.

Here is fragment of my source code for changes:

protected void CATransfer_RowUpdated(PXCache sender, PXRowUpdatedEventArgs e)
{
     Base.AddFilter.Current.ExtRefNbr = "0012224";
     Base.AddFilter.Update(Base.AddFilter.Current);
}

In case if you have any comments, ideas don't hesitate to share them via comments line.

 

 

Copy Entry Types Via Web Services In Acumatica From One Instance Into Another

Hello everybody.

Today I want to share how to copy Entty Types items in acumaticca from one instance into another instance.

The first step was to create import export settings in both instances of acumatica as described in acumatica manual similar to this screenshot:

The second step was to create project, which I decided to make as windows forms application with the following input fields:

For the button click at entry types write the following:

           var context = new ImportEt.Screen
                {
                    CookieContainer = new CookieContainer(), AllowAutoRedirect = true, EnableDecompression = true, Timeout = 1000000, Url = txtFrom.Text
                };

           var lgRes = context.Login(txtUserName.Text, txtPassword.Text);
           if (lgRes.Code == ErrorCode.OK)
           {
                var ca203000 = context.CA203000GetSchema();
                context.CA203000Clear();


                var export = context.CA203000Export(
                    new Command[]
                        {
                            ca203000.EntryType.EntryTypeID, ca203000.EntryType.DisbReceipt, ca203000.EntryType.EntryTypeDescription, ca203000.EntryType.Module, 
ca203000.EntryType.BusinessAccount, ca203000.EntryType.DefaultOffsetAccount, ca203000.EntryType.UseForPaymentsReclassification,
ca203000.EntryType.ReclassificationAccount, ca203000.EntryType.DeductFromPayment }, null, 0, false, false); context.Url = txtTo.Text; var lgRes2 = context.Login(txtUserName.Text, txtPassword.Text); if (lgRes2.Code == ErrorCode.OK) { ca203000 = context.CA203000GetSchema(); context.CA203000Clear(); foreach (var et in export) { var ca203000ImportResults = context.CA203000Submit( new Command[] { new Value { Value = et[0], LinkedCommand = ca203000.EntryType.EntryTypeID}, new Value { Value = et[1], LinkedCommand = ca203000.EntryType.DisbReceipt }, new Value { Value = et[2], LinkedCommand = ca203000.EntryType.EntryTypeDescription }, new Value { Value = et[3], LinkedCommand = ca203000.EntryType.Module }, new Value { Value = et[4], LinkedCommand = ca203000.EntryType.BusinessAccount }, new Value { Value = et[5], LinkedCommand = ca203000.EntryType.DefaultOffsetAccount }, new Value { Value = et[6], LinkedCommand = ca203000.EntryType.UseForPaymentsReclassification }, new Value { Value = et[7], LinkedCommand = ca203000.EntryType.ReclassificationAccount }, new Value { Value = et[8], LinkedCommand = ca203000.EntryType.DeductFromPayment }, ca203000.Actions.Save }); } } }

 

All activities in Acumatica are done via interface context, whic is of type screen. 

As for me, the easiest way to get some data is via command "screenID" + export. In my code you can see construction CA203000Export. Inside of it you can point to id of screen, data of which you want to receive. For example CA203000Export.

The simplest way to send something to acumatica another instance is function "screen id" + "Submit". In my code you can see method CA203000Submit. Fields Value is self-explanatory as for me. The most important and hard to understand for me was LinkedCommand. It can be name of the field. That means values has to be putted into a field. It can be action name to push on and etc. 

Another important facet of mentioned code is Actions.Save. If it is not mentioned, than code will post data to web services, but they wil not be saved.

 

Acumatica Active Directory

 

Hello,

today I want to share just simple record of how to join acumatica and your Active Directory.

For example you have the following data:

Active directory url:LDAP://RT1:389

User name yura_zale@dot.com, password: 123

For cases like this you need the following record in your web.config file:

<activeDirectory enabled="true" path="RT1:389" user="dot\yura_zale" password="123" />

 

List View In Accumatica

 

Here I want to describe how to create such simple page like this:

For reading this manual father you need to know how to add page to sitemap in accumatica. If you need me to describe this process let me know, I assume it is not challenging process.

For staff like this you need ListView template and two other classes.

The first class is used to represent single view item in grid and second class intended for navigating in the db. 

Accumatica manual recomends the following location of those two classes:

1. Create separated project ( for example IG )

2. Inside of it create Folder with the name of pages folder ( for example Investigation )

3. Add reference to the dll PX.Data

4. Create class CountryMaint:

namespace IG.Investigation
{
    public class CountryMaint : PXGraph<CountryMaint>
    {
    }
}

5. Build class library and add reference to newly created project.

I got something similar to this ( just without red rectangle ):

For now we have manager of records but without representation of records itself. Let's do it with tool called Data access class generator. Switch back to the file IG301000.aspx choose design mode and for the typename choose IG.Investigation.CountryMaint. 

Press at generate class and in the window that will appear type Country.

Here is what I seen:

Press at "Generate" button and you'll see that class which can represent single record was created exactly in DAC folder.

Now if will have desire to open developed web page you'll notice 

Error #96: View  doesn't exist.

which means that we need to add something, that is called view. What it can be? Add to the class following line

public PXSelect<Country> Countries;

and Visible="true" and then try to open page again:

Error #96: View  doesn't exist.

Why? I went nuts tring to figure out, untill I watched in manual, which sad the next phrase: 

In the Properties window, set the following property for the grid:

• DataMember:Countries

But why it speak about non-mentioned DataMember as View ? I have no idea, but if you have share it.

So, let's set it and execute. Are you ready to see result?

If to put simly this warning means that you need to add method Save to the CountryMaint class. But why Accumatica doesn't show anything I have no idea.

Let's add it:

public class CountryMaint : PXGraph<CountryMaint>
    {
        public PXSelect<Country> Countries;
        public PXSave<Country> Save;
    }

and open the page:

Cool, isn't it? Button save is ready. 

Let's add some fields for displaying. It can be done at PXGrid, via Edit content layout link:

Then you just add fields CountryCD and description. I'll omit this process because IMHO it is not complicated. Execute page again and you'll see list of countries. Enjoy !!!!

 

Acumatica Date Time Specifiers

 Hello everybody,

today I want to describe some date time specifiers in acumatica.

d - is default format pattern, so if you intend to use short date pattern, you can just ommit pattern in usage function

public static System.Text.StringBuilder MakePattern(string format, System.Globalization.DateTimeFormatInfo df)

D - long date pattern. Something similar to "Thursday, April 10, 2008"

F - long time pattern. Full date/time pattern. Something similar to "Monday, June 15, 2009 1:45:30 PM".

G - long time pattern. General date time pattern. Something like  "6/15/2009 1:45:30 PM" for "en-US" or "2009/6/15 13:45:30" for zh-CN

M equals to m and means Month day pattern "June 15"

R equals to r - RFC 1123 pattern. The custom format string is "ddd, dd MMM yyyy HH':'mm':'ss 'GMT' like "Mon, 15 Jun 2009 20:45:30 GMT"

T - long time pattern. "1:45:30"

U - long time pattern. Universal full date/time pattern. "Monday, June 15, 2009 8:45:30 PM" or "den 15 juni 2009 20:45:30" ( for sv-SE )

s - sortable date time pattern. Intended for sorting as strings. Format: "yyyy'-'MM'-'dd'T'HH':'mm':'ss". Looks like "2009-06-15T13:45:30"

t - short time pattern. 1:45 PM ( for en-US ), "13:45" ( hr-HR )

u - universal sortable date time pattern. 2009-06-15 20:45:30Z. Also for sorting as string.

y equals to Y year month pattern. Looks like June, 2009

f - short time pattern. Similar to "Monday, June 15, 2009 1:45 PM". Differs from 'F' by ommiting seconds

g - short time pattern ( at least in code ), and looks like this:

case 'g':
                    builder.Append(df.get_ShortDatePattern()).Append(' ').Append(df.get_ShortTimePattern());
                    return builder;

I was surprised because here g stands for "General date/time pattern" or  "6/15/2009 1:45 PM" while in acumatica 'g' is equal to 'f'

9 Comments

  • Bob said 

    This tells me absolutely nothing about how to use DateTime specifiers. I have no idea what this is even supposed to be.

  • docotor said 

    Hello Bob,
    thank you for your comment.
    I read again, and suppose you look for this:

    #region StatementDate
    public abstract class statementDate : PX.Data.IBqlField
    {
    }
    protected DateTime? _StatementDate;
    [PXDBDate( InputMask = "your input mask", DisplayMask = "your display mask")]
    [PXDefault]
    [PXUIField(DisplayName = "Statement Date")]
    public virtual DateTime? StatementDate
    {
    get
    {
    return this._StatementDate;
    }
    set
    {
    this._StatementDate = value;
    }
    }
    #endregion

  • docotor said

    Take notice of
    [PXDBDate( InputMask = "your input mask",
    DisplayMask = "your display mask")]

    hope it helps

  • adithar said

    I have a problem about date time.
    in acumatica standard date time if Timesmode = true
    format in screen = 00:00 AM/PM
    how to make datetime formats are second For example = 00:00:00

    thank you

  • docotor said

    I suppose that with TimesMode = true you'll not be able to achieve this.

  • adithar said

    what things must be done to achieve that format?

  • mungalim said 

    I need the help of the problems in Acumatica.
    I made the Date Time format in the database, and I set the DAC filed PXDBDateAndTime becomes
    [PXDBDateAndTime(InputMask = "dd-MM-yyyy HH:mm:ss",
    DisplayMask = "dd-MM-yyyy HH:mm:ss")]
    ,,,
    inside page already appears 20-04-2016 10:30:15,
    but for seconds can not be entered into the database, How solution when seconds can be saved to the database,,?

    thanks, waiting for reply

  • docotor said 

    So, you modify seconds at client side ( in browser ) , but those changes doesn't go to db ?