DOC - Automatically fill Project Codes in document row matrix with the value from document header or previous rows

Important Notes

The samples and information below is provided without a warranty of any kind. This post is for informational purposes and coresystems ag assumes no responsibility for errors or omissions in the information provided.


Attached is one customize optimizer rule which fills the project column with the value from the value from the document header or the previous row whenever selecting a new item. The rule is valid for all Sales and Purchasing documents.

For many business processes it is important to define the correct project for all rows in the documents. In many cases the project should be the same in all rows so this rule helps to save time and data quality by automatically filling in the values.


The sample requires coresuite Version 3.50 or higher, and SAP Business One 8.8 or higher.

Procedure to use this small solution

  1. Download the attached file FAQ_10156_Auto-fill_matrix_with_projects.cocu
  2. Import in SAP Business One via > Administration > Add-Ons > coresuite customize > Import / Export > Import rules. In the message box, select “All Active”. Click on “Import”.
To check the rule in action:
  1. Open any new Sales or Purchasing Document, for example Sales Order.
  2. Enter Business Partner and BP Project (Accounting Folder)
  3. Make sure the project column is visible (SAP Standard not coresuite time project)
  4. Add a new item in the first row and select tabulator key
  5. Check the value for the Project and see that the field is filled automatically with the value from the BP Project
  6. Adjust the project to a different project
  7. Add Item in second row and select tabulator key
  8. Check the value for the Project in the second row and see that the value is automatically filled wit the project entered in the first row.

Procedure to adjust this small solution

If you want to copy the value of a different column to the next row adjust the parameter "columnUID" with the id of the corresponding column and make sure to handle the first row accordingly.

Preview Sample (Optimizer Rule C#):

// Here Project Code (ColumnUid = 31), adjust this if you need to copy a the value of a different column to the next row
string columnUID = "31";
string ruleName = pVal.RuleInfo.RuleName.ToString();
string errorMessage = "Error in Optimizer Rule '" + ruleName + "'";
string project = "";
Matrix oMatrix = Matrix.GetFromUID(pVal.Form, "38");
int currentRow = pVal.Row - 1;
if (currentRow == 0)
// Get the value from the BP Project under Accounting folder
project = TextEdit.GetFromUID(pVal.Form, "157").Value;
// Get the value from the previous row
project = oMatrix.GetValue(columnUID, currentRow - 1);
oMatrix.SetValue(columnUID, currentRow, project);
catch(System.Exception ex)
StatusBar.WriteError(errorMessage + ": " + ex.Message);
Debug.WriteMessage(errorMessage + ": " + ex.Message, Debug.DebugLevel.Exception);
return true;
Was this article helpful?
1 out of 2 found this helpful
Have more questions? Submit a request



Please sign in to leave a comment.