How to increase the length of out-of-the-box fields? - acumatica

Currently, we are using the full 30 characters of the InventoryItem.InventoryCD field, but we need more. How can we increase this field length to 45 characters ?

This can easily be done by creating a customization project containing a database script. This guide will be specific to InventoryItem.InventoryCD, but the idea can be applied to any fields. See the Notes sections at the end for more info.
For InventoryCD, here are the 3 steps you need to follow.
1. Database script in a customization project
Navigate to the Customization Projects screen (SM204505) and create a new customization project. Go to the DB Scripts section, click on Add and choose Script.
Copy the script matching with your database and click OK :
SQLServer
DROP INDEX [Inventory_InventoryCD] ON [InventoryItem]
ALTER TABLE InventoryItem ALTER COLUMN InventoryCD nvarchar(45) NOT NULL
CREATE UNIQUE NONCLUSTERED INDEX [Inventory_InventoryCD] ON [dbo].[InventoryItem]
(
[CompanyID] ASC,
[InventoryCD] ASC
)
MySQL
ALTER TABLE InventoryItem
DROP INDEX Inventory_InventoryCD;
ALTER TABLE InventoryItem CHANGE InventoryCD InventoryCD NVARCHAR(45) NOT NULL;
CREATE UNIQUE INDEX Inventory_InventoryCD
ON InventoryItem (CompanyID, InventoryCD);
These scripts only alter the columns we need but to do so, we drop the existing index and recreate it at the end. You can run these commands manually to test them before adding them to your customization.
2. Publish project and restart application
We have all we need in this customization project. Publish it by going to the Publish menu and click on Publish with Cleanup. When it successfully publishes, navigate to System > Management > Process > Apply Updates screen (SM203510). We are going to Restart Application which will restart the whole website. Make sure to notify all your users to save their work before doing it! When you are ready, click on Restart Application.
This step will ensure that the framework discards the previous database schema and loads the up-to-date schema in memory.
3. Change segment length
The last step will be to modify the INVENTORY segment to allow longer length on our InventoryCD. Navigate to Configuration > Common Settings > Segmented Keys > Segmented Keys screen (CS202000) and select INVENTORY as the Segmented Key ID. Apply the new length to the segment in the grid and Save. You are now ready to test !
Notes
If you want to modify any out-of-the-box fields in Acumatica, step 3 will have to be adapted to the field.
3a. Alternate DAC modifications
In this steps
, you would need to make sure that the DAC field type attribute matches the new columns length. As an example, a DAC string field could have been changed from
[PXDBString(30, IsUnicode = true)]
to
[PXDBString(45, IsUnicode = true)]
You can find more info on DAC fields attributes modifications at this link :
https://help.acumatica.com/(W(11))/Wiki/ShowWiki.aspx?pageid=1911428f-d4ca-4207-9396-a744db21cdfb

Be aware that increasing field length may corrupt data during upgrade as database schema that is used for upgrade procedure is defined inside %AcumaticaPath%/Database/database_schema.xml
For smooth upgrade don't forget to modify database_schema.xml:
<col name="InventoryCD" type="NVarChar(30)" />
to
<col name="InventoryCD" type="NVarChar(45)" />
Otherwise you may receive "string will be truncated" errors followed by data corruption.

Related

Need help in view delegate in custom screen

we created a custom screen which displays list of sales data based on filter conditions like (today, yesterday, this week, this month, this quarter, this year), we created a SQL view for this and then from VIEW we created and DAC and using it in custom screen. We also have filters in our screen. for filter conditions we are using view delegate and returning the data. the question is why the screen takes too long around 70 seconds to load 2K records. Is using view delegate decrease the speed of loading data. We can go with GI but we need to display images in the GRID so we opted for custom screen and also we have some report button in header which prints report. as we can't show images in GI we chose this.
The slowness you see is most likely caused by combination of two reasons.
When you use BQL view, it in fact requests only the number of records you see on the screen. For instance if you have grid with paging and only 20 records are visible on the page, the SQL select will have TOP 20 limitation. However, once you have select delegate, that optimization stops working since the framework does not know what you'd like to do with the data you select. The solution here would be to use SelectWithViewContext with DelegateResult return object instead of regular select. In that case user filtering, pagination and ordering is preserved in the select. (Use this method only if resulting records on the screen relate as 1 to 1 to the records you select. If you use any kind of aggregation or inserting records from 2 different select, that approach does not work)
Example:
protected virtual IEnumerable ardocumentlist()
{
PXSelectBase<BalancedARDocument> cmd =
new PXSelectJoinGroupBy<BalancedARDocument,
...
OrderBy<Asc<BalancedARDocument.docType, //Set necessary sorting fields: use the key fields
Asc<BalancedARDocument.refNbr>>>> //Set necessary sorting fields: use the key fields
(this);
PXDelegateResult delegResult = new PXDelegateResult
{
IsResultFiltered = true, //set these fields to indicate that the result does not need re-filtering, resorting and re-paging
IsResultTruncated = true,
IsResultSorted = true
}
foreach (PXResult<BalancedARDocument> res_record in cmd.SelectWithViewContext())
{
// add the code to process res_record
delegResult.Add(res_record);
}
return delegResult;
}
Probably you don't have proper indexes on your table since even if you select all 2k records at once it should not result in 70 seconds load time. Recommendation here would be to use the request profiler to catch the exact SQL generated (https://help-2020r2.acumatica.com/Help?ScreenId=ShowWiki&pageid=e4c450bb-86bc-4fb2-b7e6-1f715abe3c8b) and execute the SQL in MS SQL Management studio with option 'Include Actual Execution Plan' (https://learn.microsoft.com/en-us/sql/relational-databases/performance/display-an-actual-execution-plan?view=sql-server-ver15) . Usually in this mode the MS SQL server suggests the indexes needed to speed up the query execution.

Is there a way to display new column in Orders html table in Kentico without touching the code?

I'm using Kentico MVC v12 with a fresh installation of DancingGoat(MVC) template.
I've modified the "E-commerce" module by adding a new column in the "Order" table.
I would like to be able to see it on the "Order" module in the list page.
I see in the "User interface" tab that it uses an "aspx" page.
In it I see that it calls an "ascx" page that uses a "UniGrid" component and specify the columns directly in a data attribute.
I don't like the idea to modify this file to display my new column because I see this website as the foundation of my next features, I would like to avoid as much as possible to touch the code of the website template, do you know if there is an other way ?
Maybe I'm missing a configuration somewhere else ?
Thank you by advance !
Update 06-03-2019:
I tried the solution of Peter Mogilnitski but it doesn't work :x
I added the column in the data source
Then I checked the column in widget configuration
Nothing is displayed
I debugged the sql query, I don't see my column in the query, is there an other configuration to do somewhere else ?
Update 08-03-2019:
The support of Kentico confirmed that the solution I proposed that was confirmed by #Rui was the right way to do it.
Thank you everyone !
If you want the custom field to appear in the UI, you will have to make change to the ascx page. You will need to make a note to that because you will likely need to update it during upgrade or hotfix (less likely)
Other than adding the data field to Columns, you will also need to add ug:column to the section
<ug:Column Name="SAPID" Source="SAPID" Caption="SAPID" Sort="SAPID" />
Yes. There is. This is the widget called orders:
You need to go to widgets, select orders widget and add your column to visible columns
Now go to store overview:
Click on properties of latest orders (this is orders widget used all over the store) and scroll down to column and make your column checked.

Extend Cases to include an additional tab with a list (AEF)

I have been extending Acumatica screens by adding new fields accordingly. However, for this particular scenario, I want to create a new tab in the Cases screen.
This tab would include a list of items. These list of items would be a custom table that I will be adding to Acumatica.
Is this possible?
And is this the correct list of Steps?
1. Create table in Acumatica for the list of items
2. Create DAC for the new table
3. Extend the Cases Graph and add a new Data View (i.e. PXSelect)
4. Edit the Cases screen so that a table and grid are added accordingly
5. Link the grid to the Data View through the Data Member property
I am not sure whether you would also need to implement some additional events, but I believe that if the DAC has the correct link to the Case and the correct attributes ... it should work.
Would be much appreciated if someone helps to confirm the above approach please.
Adding a tab page containing a grid bound to a DataView on a custom DAC in the case entry screen is a supported scenario.
There are a few ways to do it. Whether you are working on a Customization Project or an Extension Library will influence how you approach this requirement.
Your steps seems all right. Here's how I would do it in a Customization Project:
Create a new table in the database using a DB management utility (ex: SQL Server Management Studio). Restart WebSite instance or IIS to make sure Acumatica picks up DB schema change.
In DB script section of the customization project, add the new table and check import table schema from database. This will ensure publishing the customization project will create the table in the database.
Create a new DAC for the new table, DAC name should be the table name.
Extend the case entry graph (CRCaseMaint) and add a new DataView on your DAC.
Edit the case entry screen (CR306000), add a TabPage and a grid.
Bound the new grid to your DataView using the DataMember property

How to get last created record in an entity in dynamics crm online?

I need to create a view in a page and this view must contain only the last created record. I tried with view filter but it doesn't allow to get the last
created record. Is there any way to do this please?
Thanks in advance,
Create a system view on your target entity that is sorted by createdon descending and then publish the entity. This query will return multiple records, and the most recently created one will be at the top.
Download the XrmToolbox, unblock the zip, and extract it somewhere on your hard drive.
Download FetchXML Builder XrmToolbox plugin, unblock the zip, and extract it into XrmToolbox's plugins folder.
Start XrmToolbox, connect to your org, and click the FetchXML Builder tool.
Open -> View -> specify your entity (I had to play with the autocomplete box a little bit to get it to work) -> select the view you created in step 1. This will load the view in the builder.
Select the Fetch node in the tree on the left. On the right, you will see a field called Top. Specify 1.
Choose Save->Save View. That should do it!

custom Dropdown control issue

version: 5.20.1752
I have created one custom dropdown control on contact form CR302000, the control looks good on screen, but the value of the control can't be saved (no error, but just nothing is saved), nor loading data from database.
I also have a custom textbox on that screen ,saving and loading the value of it both are working okay.
here is DAL code for dropdown:
[PXStringList(new string[] {"1","2","3"}, new string[] {"EN","FR","BI"})]
[PXDefault("1")]
[PXUIField(DisplayName="Language")]
What should I do to make custom dropdown to work?
Thanks
You can delete your column from the table manually using your preferred Db mgmt tool (eg. SQL Management Studio). Or if the client is hosted, you can create a SQL script which drops the column from the table. Then publish that SQL script.
Since you use version 5.20, consider building an extension table and DAC extension, for your user field. You can find the details to create them in the Acumatica T300 course.
Jeff is correct. You need to use the proper declarations - PXDBString, not PXString. What is the name of your DAC that you work with? Make sure it is not a PXProjection.

Resources