Parsing Formula in Report Mail Settings - acumatica

I'm trying to show an email pop up window with an attached report. I want the email fields in the popup window to be populated with the attached report's mail settings - similar to what happens when you click the "Send" button when running the report directly. I'm trying to do this in a PXAction method.
I've got it mostly done but, I'm having a problem if the Mail Settings have a formula in them. For instance if the Subject is set to "=[table].[field]" I get "=[table].[field]" in the Subject box for my email popup window instead of the value of table.field.
Any ideas on how to get the values of the Mail Settings fields in the report instead of the verbatim text?
TIA!

Here's what worked for me. I'm sure there's a way to dispense with the code that removes the "=" but, this got what I needed.
protected string GleanMailSetting(Report report, ReportNode reportNode, string settingText)
{
if ((string.IsNullOrEmpty(settingText)) || (!settingText.StartsWith("=")))
return settingText;
string trimmedText = settingText.TrimStart(new char[] { '=' });
PX.Common.Parser.ExpressionNode node = Reports.Parser.ReportExprParser.Parse(trimmedText, report);
node.Bind(report.DataSource);
return (string)node.Eval(reportNode.DataItem);
}

Related

How can I open an editable, sendable e-mail screen with prepopoulated values?

I am trying to create an e-mail with to and from already filled in. To create the e-mail, I'm creating a graph instance of CREmailActivityMaint. Whenever I attempt to assign new objects to the CREmailActivityMaint.CurrentMessage or CREmailActivityMaint.Message objects so that I can set values, the opening page becomes uneditable and Send is hidden:
Also when I enter values, not all of them show. In this, I entered To, From, Subject, Summary, and Body, but Body and Summary show nothing. Also if I attempt to save, I get an error stating that the Summary, To, and Subject are blank:
CREmailActivityMaint graph = CreateInstance<CREmailActivityMaint>();
graph.Message.Current = graph.Message.Insert();
graph.Message.Current.MailTo = "other#test.com";
graph.Message.Current.MailCc = "another#test.com";
graph.Message.Current.MailBcc = "bcc#test.com";
graph.Message.Current.Subject = "Subject";
graph.Message.Current.Body = "Body";
graph.Message.Cache.IsDirty = false;
PXRedirectHelper.TryRedirect(graph, PXRedirectHelper.WindowMode.NewWindow);

pentaho modify and print a parameter while exporting to excel

I use pentaho report designer. I have got businessdate parameter in my prpt file. This has the value of the date range which is used to filter the sql query. I am able to handle and modify it while exporting to html however I have a problem in exporting to excel.
The date range comes in the formats below:
- BETWEEN {d '2014-01-01'} AND {d '2014-01-31'}
- IN ({d '2014-01-14'},{d '2014-01-15'}, {d '2014-01-19'} ,{d '2014-01-20'},{d '2014-01-21'})
I like to find out max and min date and display it. However in this case with excel, I am happy with displaying them separated with commas like shown below.
- 2014-01-01, 2014-01-31
- 2014-01-14, 2014-01-15, 2014-01-19, 2014-01-20, 2014-01-21
If I use the basic formula show below, it works in in excel but it does not work when I apply it to excel - formula section of the businessDate element in pentaho report designer.
=TRIM(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(B4,"{d '",""), "BETWEEN", ""), "IN", ""),"'}",", "), " AND ", ""),")",""),"(",))
It does not have to be this way. I am happy with any method suggested to format this raw date range before printing to excel.
Thank you in advance.
After wasting a lot of time, I have found a way which works for all export types. As I said in my question, I was modifying date for html print by using "Structure Tab" --> Select "Master Report" --> "Attributes" Tab --> html -> "append-header" attribute.
<script type="text/javascript">
function init() {
var tableList = document.getElementsByTagName("table");
var businessDate = document.getElementById("businessDatePeriodSelected");
businessDate.innerHTML = businessDate.innerHTML+"testDateModified";
}
window.onload = init;
</script>
This piece of code does the job. However just for html. I needed to come up with something new. I was looking for a solution for excel and pdf exports as well.
HERE IS THE SOLUTION:
Click on "Data" tab next to the "Structure" tab on the right top side. You will see "Functions" in the tree. Right click and hit "Add functions". Select "Script" -->"Bean-Scripting Framework (BSF)". Select function created under Functions. Give it a name and add the code below to the "Expression" section. [This does not need a starting or ending tag]
/* businessdate is one of my parameters that I like to display on the report.
dataRow is automatically recognized by the interpreter which can be used for calling parameter values. It seems like came out of nowhere.*/
String value = dataRow.get("businessdate");
value= value.replaceAll("[^0-9\\-\\{\\}]", "");
value= value.replaceAll("[\\{]", ""); // replace all {
value= value.replaceAll("[\\}]", ","); // replace all }
value= value.substring(0, value.length()-1);
String[] dateArr = value.split(",");
return dateArr[0] +" - "+dateArr[dateArr.length-1];
The last thing you need to do is drag and drop your function somewhere suitable on your report. It will locate a textbox which will display the modified businessdate.
If you like to print a parameter on your pentaho report, this does the job for all exports (html, pdf and excel). You can also modify it before printing. This link pretty helpful as the syntax is slightly different at some points.
good luck.

Adding content control throws an exception dynamically

I am fairly new to Word Addin development. Fortunately I was able to do almost everything but stuck at some simple issue I belive.
I want to insert plain text controls dynamically at the selected range. For this I am using the following:
currentDocument = application.ActiveDocument;
foreach(var field in myFieldsList)
{
Microsoft.Office.Interop.Word.Range rng = currentDocument.ActiveWindow.Selection.Range;
object oRng = rng;
var contentControlPlain = application.ActiveDocument.ContentControls.Add(Microsoft.Office.Interop.Word.WdContentControlType.wdContentControlText, ref oRng);
contentControlPlain.Tag = formField.FormFieldId.ToString();
contentControlPlain.SetPlaceholderText(null, null, " <" + formField.FormFieldName + "> ");
contentControlPlain.LockContentControl = (formField.TypeName.Trim() == "Blank");
}
Code seems to be working fine but when I try to insert the second field it complains saying:
This method or property is not available because the current selection partially covers a plain text content control.
I understand that addin is trying to insert next content control into the previously inserted plain text control. But I tried giving some other range and could not fix it.
Any help is greatly appreciated.
Thanks.
After adding every content control use
Application.Selection.Start = lastControl.Range.End+1

Using Selenium RC, Excel (Data Driven) and SeleniumException

I'm working on an automation project right now which is to create an account on a specific site.
There are different set of rules that needs to be checked. There needs to be a set of data where some of the required fields are missing, the email address used to create on the account is already used on the system and the last set is where the account could be created. The general flow of the process is:
Run SeleniumRC
Get Data from ExcelFile
The Excel Data is composed of different sets.
Set A : Missing Required Fille
Set B : Email address is already used
Set B : Complete/Correct Data
Go the site.
Input all data.
If set A :
Then creation will not process.
It will provide output:
Row Number - Error
If set B :
Then creation will not process.
It will provide output:
Row Number - Error
If set C :
It will create account.
Provide Screenshot ounce login
Go back to step 2 until all rows found on the Excel File is completely checked.
Output will be placed on another Excel File
I am able to run the process however that is if I am using a flag for each entry in the Excel File. This does defeat the purpose of checking the creation process works as expected.
My Selenium Command goes like this:
public void test_CreateAccount() throws Exception {
//Some code to data from Excel Sheet
totalrows = s.getRows();
int i = 1;
while(i<totalrows){
//Some command to set data to string names
RowNum = s.getCell(0, i).getContents();
FName = s.getCell(1, i).getContents();
selenium.open // Go to a specific site
selenium.click("css=a > img"); // click create account
selenium.waitForPageToLoad("60000");
selenium.type("name=q1557", FName);
selenium.type("name=q1558", LName);
selenium.type("name=q1578", JobTitle);
selenium.type("name=q1579", email1);
selenium.type("name=email_confirm", email2);
selenium.type("name=q1583", phone);
selenium.type("name=q1584", ext);
selenium.type("name=q1585", fax);
selenium.type("name=q1587", company);
selenium.select("name=q1588", organization);
selenium.type("name=q1591", address1);
selenium.type("name=q1592", address2);
selenium.type("name=q1593", city);
selenium.select("name=q1594",state);
selenium.type("name=q1595", other);
selenium.type("name=q1598", zip);
selenium.select("name=q1596", country);
selenium.type("name=q1599", password1);
selenium.type("name=password_confirm", password2);
selenium.type("name=q1600", question);
selenium.type("name=q1601", answer);
selenium.click("name=submit_signup"); // click submit
i = i + 1;
}
}
When I run the command above, this does work. If data is SET A or B, then error occurred. If data is SET C, then it will create and then done.
In order to check all data within the Excel file or continue until end of totalrows, I placed a flag.
In the middle of the command I place something like
if(flag=1){ //input process only until submit button. }else
if(flag=2){ //input process only until submit button. }else{ create
}
I tried using try and catch with SeleniumException however it still does not work. Can you provide me with any idea on how to do this.

vc++ MFC Project

In Vc++ 6.0 mscomm control,please any body explain this function How it works ,what it does
if (m_comm.GetCommEvent()==2 )
{
VARIANT in_dat;
in_dat = m_comm.GetInput();
CString strInput(in_dat.bstrVal);
m_input = m_input + strInput;
UpdateData(FALSE);
}
The code checks whether a comm event occured. If it did, then the input data is obtained from the control and appended to m_input. Afterwards, the data is updated.
The code does not offer much more insight.
Just in case you don't know, "the data is updated" in HS' post means 'the dialog box fields are updated to show the new data'

Resources