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.
Purpose
Attached is one rule that will add the Business Partner name on the Journal Remarks of the A/R Invoice before is added, thus also passing this Remark to the Journal Entry that is created in the Add process.
Requirements
The templates require coresuite Version 3.50 or higher, and SAP Business One 8.8 or higher.
Procedure to use these templates
1. Download the attached BUP_10172_Test_Qu... file
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:
Just create a new Marketing Document and press the Add button. A message box with all the BP Properties marked "Y" is printed with confirmation button.
Procedure to adjust these templates
Only forms 133,140 are supported. If other marketing documents are needed just add the form ID on the ItemUID on the Trigger area in the Optimizer window.
Preview Sample (Optimizer Rule C#):
/*
***** General Information *****
Creator: coresystems software USA, laja
Create Date: 2012 07 10
***** StartConfDesc *****
Test query groups that are marked as "Y" before updating/adding marketing document
***** EndConfDesc *****
***** Updates *****
YYYY-MM-DD, name: Update Comment
*/
string ruleName = pVal.RuleInfo.RuleName.ToString();
string errorMessage = "Error in [Optimizer Rule] '" + ruleName + "'";
string carriageReturn = "\r\n";
string mySQL="";
string myErrorMessage="";
System.Globalization.CultureInfo ci = SwissAddonFramework.Utils.Misc.GetSAPCulture();
try
{
string cardCode = TextEdit.GetFromUID(pVal.Form, "4").Value;
for (int i = 1; i <= 64; i++) {
if (i >= 2) {mySQL = mySQL + " UNION ALL " + carriageReturn;}
mySQL = mySQL +
@"SELECT TOP 1 OCRD.QryGroup" + i.ToString() + @", OCQG.GroupName, OCQG.GroupCode
FROM OCRD, OCQG
WHERE CardCode = '" + cardCode + "' and OCQG.GroupCode = '" + i.ToString() +
"' AND QryGroup" + i.ToString() + " = 'Y'" + carriageReturn;
}
System.Data.SqlClient.SqlCommand cmd = new System.Data.SqlClient.SqlCommand();
cmd.CommandText = mySQL;
using (System.Data.SqlClient.SqlDataReader sdr = SwissAddonFramework.B1Connector.GetB1Connector().ExecuteQuery(cmd)){
if (sdr.HasRows) {
bool firstRow = true;
while (sdr.Read()){
if (firstRow) {
myErrorMessage = "As seguintes propriedades foram selecionadas para esse parceiro de negócios, você confirma: " + carriageReturn;
firstRow = false;
}
myErrorMessage = myErrorMessage + sdr["GroupCode"] + " - " + sdr["GroupName"] + carriageReturn;
}
MessageBox.Show(myErrorMessage, "Confirmo ");
}
}
}
catch (System.Exception ex)
{
MessageBox.Show(errorMessage + ": \n" + ex.Message, "OK");
StatusBar.WriteError(errorMessage + ": " + ex.Message);
Debug.WriteMessage(errorMessage + ": " + ex.Message, Debug.DebugLevel.Exception);
return false;
}
return true;
Comments
0 comments
Please sign in to leave a comment.