Memo Before Adaptor Method 9.05.701

Jose,
That worked....Thanks again.

Simon
Hello,
I have been working on some very rudimentary obfuscation code to alert and prevent users from saving particular strings in the issuetext on Cases and Calls. This works perfectly, however I needed to replicate the functionality over to memos, so with a few alterations to the beforeadaptor method on the memo form I thought I had it.

On testing it appears that writing back to edvMemo.dataView[edvMemo.Row]["MemoText"] does not appear to work and when I debug in visual studio and include an afteradaptor I see that the value has not changed.

Has anyone seen issues where altering a field in the before adaptor does not save?  Perhaps there is another way I have not thought of. 

Here's is some sample code, basically we are using a regular expression to find 16 consecutive digits then hiding the first 12.  Very similar code works exactly the same on the HDCase and the CRM Call forms without issue. It is a bit of a pain to put it in multiple locations, but I am not too sure if you could or how to put it into an assembly and call it from a BPM.

using System.Text.RegularExpressions;
using System.Collections;

    private void oTrans_adapter_BeforeAdapterMethod(object sender, BeforeAdapterMethodArgs args)
    {
// ** Argument Properties and Uses **
        // ** args.MethodName **
        // ** Add Event Handler Code **
   
        // ** Use MessageBox to find adapter method name
        //EpiMessageBox.Show(args.MethodName);
           
      EpiTextBox txtMemo = (EpiTextBox)csm.GetNativeControlReference("58e22dfa-a689-403c-9197-e4242ee8f7bf");
                                                           
        MatchCollection matches;
           
        switch (args.MethodName)
        {
            case "Update":
                EpiDataView edvMemo = (EpiDataView)oTrans.EpiDataViews["Memo"];
                string strMemoText = (string)edvMemo.dataView[edvMemo.Row]["MemoText"];
                string strRegex1 = "";
                bool morePages = false;
                UserCodes userCodesBO = new UserCodes(((Session)oTrans.Session).ConnectionPool );
                UserCodesDataSet userCodesDS = userCodesBO.GetRows("CodeTypeID = 'TEST'", "CodeTypeID = 'TEST'", 0, 0, out morePages);
           
                foreach (DataRow row in userCodesDS.Tables["UDCodes"].Rows)
                {
                string CodeDesc = row["CodeDesc"].ToString();
             strRegex1 = strRegex1  + @"(\b" + CodeDesc.ToString() + @"\b)|";
                 }
                try {
                    strRegex1 =  "(?i)" + strRegex1.Substring(0,(strRegex1.Length-1));
                    }
                catch (System.Exception ex)
                    {
                        ExceptionBox.Show(ex);
                    }
   
                    // regex identifiers  (?i) any case  | or  \b<put the search between here\b  eg (?i)(\bCodeDesc2\b)|(\bCodeDesc2\b |.....etc
               
              if (strMemoText != "" )
                 {              
                   string strRegex = @"\b[0-9]{12}(?=[0-9]{4}\b)" + "|" + strRegex1 ;       
                   Regex re = new Regex(strRegex);
                   matches = re.Matches(txtMemo.Text);
                   if (matches.Count > 0)
                      {
              
                        DialogResult dialogResult = EpiMessageBox.Show(" A message" + Environment.NewLine + "Another message","Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                        if ((dialogResult == DialogResult.OK))
                          {
                            txtMemo.Text = Regex.Replace(txtMemo.Text, @"\b[0-9]{12}(?=[0-9]{4}\b)", new string('X', 12));
                            edvMemo.dataView[edvMemo.Row]["MemoText"] = txtMemo.Text;
                          }
                      }
                   }   
                break;
        }
   
    }


Any comments, suggestions appreciated. I suspect that this may be an issue with the specific Memo adapter. If anyone has 702 or above and has a moment to test, it should be as easy as creating a customization on the memo and adding a before adapter and adding in the following assembly references.


Epicor.Core.Mfg.BL.ConnectionPool.dll

Epicor.Mfg.AD.Usercodes.dll (not sure if you need all dlls for the UserCodes or not)

Epicor.Mfg.BO.Usercodes.dll

Epicor.Mfg.IF.Usercodes.dll


Kind Regards

Simon Hall

After you assign your value you need to invoke the epidataview notify command. Or alternatively toy can use the BeginEdit and EndEdit methods on the data view row

On Jun 17, 2015 1:01 AM, "s1mhall@... [vantage]" <vantage@yahoogroups.com> wrote:

Â
<div>
  
  
  <p>Hello,<br>I have been working on some very rudimentary obfuscation code to alert and prevent users from saving particular strings in the issuetext on Cases and Calls. This works perfectly, however I needed to replicate the functionality over to memos, so with a few alterations to the beforeadaptor method on the memo form I thought I had it.<br><br>On testing it appears that writing back to edvMemo.dataView[edvMemo.Row][&quot;MemoText&quot;] does not appear to work and when I debug in visual studio and include an afteradaptor I see that the value has not changed.<br><br>Has anyone seen issues where altering a field in the before adaptor does not save?  Perhaps there is another way I have not thought of.  <br><br>Here&#39;s is some sample code, basically we are using a regular expression to find 16 consecutive digits then hiding the first 12.  Very similar code works exactly the same on the HDCase and the CRM Call forms without issue. It is a bit of a pain to put it in multiple locations, but I am not too sure if you could or how to put it into an assembly and call it from a BPM.<br><br>using System.Text.RegularExpressions;<br>using System.Collections;<br><br><p><span>    private void oTrans_adapter_BeforeAdapterMethod(object sender, BeforeAdapterMethodArgs args)<br>    {<br>// ** Argument Properties and Uses **<br>        // ** args.MethodName **<br>        // ** Add Event Handler Code **<br>    <br>        // ** Use MessageBox to find adapter method name<br>        //EpiMessageBox.Show(args.MethodName);<br>            <br>      EpiTextBox txtMemo = (EpiTextBox)csm.GetNativeControlReference(&quot;58e22dfa-a689-403c-9197-e4242ee8f7bf&quot;);<br>                                                            <br>        MatchCollection matches;<br>            <br>        switch (args.MethodName)<br>        {<br>            case &quot;Update&quot;:<br>                EpiDataView edvMemo = (EpiDataView)oTrans.EpiDataViews[&quot;Memo&quot;];<br>                string strMemoText = (string)edvMemo.dataView[edvMemo.Row][&quot;MemoText&quot;]; <br>                string strRegex1 = &quot;&quot;;<br>                bool morePages = false;<br>                UserCodes userCodesBO = new UserCodes(((Session)oTrans.Session).ConnectionPool );<br>                UserCodesDataSet userCodesDS = userCodesBO.GetRows(&quot;CodeTypeID = &#39;TEST&#39;&quot;, &quot;CodeTypeID = &#39;TEST&#39;&quot;, 0, 0, out morePages);<br>            <br>                foreach (DataRow row in userCodesDS.Tables[&quot;UDCodes&quot;].Rows)<br>                {<br>                string CodeDesc = row[&quot;CodeDesc&quot;].ToString();<br>             strRegex1 = strRegex1  + @&quot;(&#92;b&quot; + CodeDesc.ToString() + @&quot;&#92;b)|&quot;;<br>                 }<br>                try {<br>                    strRegex1 =  &quot;(?i)&quot; + strRegex1.Substring(0,(strRegex1.Length-1));<br>                    }<br>                catch (System.Exception ex)<br>                    {<br>                        ExceptionBox.Show(ex);<br>                    }<br>    <br>                    // regex identifiers  (?i) any case  | or  &#92;b&lt;put the search between here&#92;b  eg (?i)(&#92;bCodeDesc2&#92;b)|(&#92;bCodeDesc2&#92;b |.....etc<br>                <br>              if (strMemoText != &quot;&quot; )<br>                 {               <br>                   string strRegex = @&quot;&#92;b[0-9]{12}(?=[0-9]{4}&#92;b)&quot; + &quot;|&quot; + strRegex1 ;        <br>                   Regex re = new Regex(strRegex);<br>                   matches = re.Matches(txtMemo.Text);<br>                   if (matches.Count &gt; 0)<br>                      { <br>               <br>                        DialogResult dialogResult = EpiMessageBox.Show(&quot; A message&quot; + Environment.NewLine + &quot;Another message&quot;,&quot;Warning&quot;, MessageBoxButtons.OK, MessageBoxIcon.Warning);<br>                        if ((dialogResult == DialogResult.OK))<br>                          {<br>                            txtMemo.Text = Regex.Replace(txtMemo.Text, @&quot;&#92;b[0-9]{12}(?=[0-9]{4}&#92;b)&quot;, new string(&#39;X&#39;, 12));<br>                            edvMemo.dataView[edvMemo.Row][&quot;MemoText&quot;] = txtMemo.Text;<br>                          } <br>                      }<br>                   }    <br>                break;<br>        }<br>    <br>    }<br></span></p><p><br></p><p>Any comments, suggestions appreciated. I suspect that this may be an issue with the specific Memo adapter. If anyone has 702 or above and has a moment to test, it should be as easy as creating a customization on the memo and adding a before adapter and adding in the following assembly references.</p><p><br></p><p>Epicor.Core.Mfg.BL.ConnectionPool.dll</p><p>Epicor.Mfg.AD.Usercodes.dll (not sure if you need all dlls for the UserCodes or not)<br></p><p>Epicor.Mfg.BO.Usercodes.dll</p><p>Epicor.Mfg.IF.Usercodes.dll</p><p><br></p><p>Kind Regards</p><p>Simon Hall<br><span></span></p>

</div>
 


<div style="color:#fff;min-height:0;"></div>
Thanks Jose,
I'll give that go.  Can you explain why nearly exactly the same code works in the HDCase and CRMCall forms?

Simon