Follow

BUP - Verify BP has email when generating a marketing document

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 verifies that the BP record has an email address when you are trying to add a marketing document.


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_10171_Verify_... 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 press the Add button. Make sure the BP you are using doesn't have an email address in its record.


Procedure to adjust these templates

Only form types 133,140,180,179 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 *****
If the BP email address is not present when generating a marketing document, then advise to add and don't add document.
***** EndConfDesc *****
 
***** Updates *****
YYYY-MM-DD, name: Update Comment
*/
string ruleName = pVal.RuleInfo.RuleName.ToString();
string errorMessage = "Error in [Optimizer Rule] '" + ruleName + "'";
try 
{
string CardNumber = TextEdit.GetFromUID(pVal.Form, "4").Value;

string mySQL = "SELECT TOP 1 COALESCE(E_Mail,'') FROM OCRD WHERE CardCode='" + CardNumber + "'";
string myEmail = LayoutHelper.LD.QueryData(mySQL);
string myRegex = @"^[\w!#$%&'*+\-/=?\^_`{|}~]+(\.[\w!#$%&'*+\-/=?\^_`{|}~]+)*"
+ "@"
+ @"((([\-\w]+\.)+[a-zA-Z]{2,4})|(([0-9]{1,3}\.){3}[0-9]{1,3}))$";

bool validEmail = System.Text.RegularExpressions.Regex.IsMatch(
myEmail,
myRegex,
System.Text.RegularExpressions.RegexOptions.IgnoreCase);

if (!validEmail) {
MessageBox.Show("Please define an email address in the BP record", "OK");
return false;
}
}
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 true;
Was this article helpful?
0 out of 0 found this helpful
Have more questions? Submit a request

0 Comments

Please sign in to leave a comment.