I’ve created a UD field on PartRev for Draw Rev. I would like this field to be read only if Approved = True.
Therefore, I don’t want to set this in Extended Properties as I don’t want it to be read only always.
I could create a BPM to prevent users editing this field if Approved = True but would prefer to make it read only.
I’ve tried using customization wizard to do this but can’t seem to get it to work. I do not have scripting abilities.
You should be able to do what you want with Row Rules. Go into the help and find the tools user guide under customization and there should be a section that has an explanation on how row rules work. It’s all wizard based so you don’t have to write the code.
Yep. One quirky thing, though, is that usually EpiReadOnly is the setting style you’d expect to pick in the Rule Action… However, Part Revision is behaving differently than most other forms I’ve worked with. If you select Disabled, it should do what you need. See screen shot below.
Click New Row Rule, fill in the fields, hit the right arrow, then below click New Rule Action, then fill in the fields, hit the right arrow (add as many actions per rule as you need), and then click the Update Code button.
// **************************************************
// Custom code for PartForm
// Created: 16/06/2021 8:48:10 am
// **************************************************
extern alias Erp_Contracts_BO_Part;
extern alias Erp_Contracts_BO_PartPlantSearch;
extern alias Erp_Contracts_BO_PO;
extern alias Erp_Contracts_BO_PartOnHandWhse;
extern alias Erp_Contracts_BO_Vendor;
extern alias Erp_Contracts_BO_VendorPPSearch;
using System;
using System.ComponentModel;
using System.Data;
using System.Diagnostics;
using System.Windows.Forms;
using Erp.Adapters;
using Erp.UI;
using Ice.Lib;
using Ice.Adapters;
using Ice.Lib.Customization;
using Ice.Lib.ExtendedProps;
using Ice.Lib.Framework;
using Ice.Lib.Searches;
using Ice.UI.FormFunctions;
public class Script
{
// ** Wizard Insert Location - Do Not Remove ‘Begin/End Wizard Added Module Level Variables’ Comments! **
// Begin Wizard Added Module Level Variables **
// End Wizard Added Module Level Variables **
// Add Custom Module Level Variables Here **
public void InitializeCustomCode()
{
// ** Wizard Insert Location - Do not delete 'Begin/End Wizard Added Variable Initialization' lines **
// Begin Wizard Added Variable Initialization
// End Wizard Added Variable Initialization
// Begin Wizard Added Custom Method Calls
this.epiButtonC1.Click += new System.EventHandler(this.epiButtonC1_Click);
SetExtendedProperties();
CreateRowRulePartRevApprovedEquals_true();;
// End Wizard Added Custom Method Calls
}
public void DestroyCustomCode()
{
// ** Wizard Insert Location - Do not delete 'Begin/End Wizard Added Object Disposal' lines **
// Begin Wizard Added Object Disposal
this.epiButtonC1.Click -= new System.EventHandler(this.epiButtonC1_Click);
// End Wizard Added Object Disposal
// Begin Custom Code Disposal
// End Custom Code Disposal
}
private void epiButtonC1_Click(object sender, System.EventArgs args)
{
// ** Place Event Handling Code Here **
SearchOnCustomerAdapterShowDialog();
}
private void SearchOnCustomerAdapterShowDialog()
{
// Wizard Generated Search Method
// You will need to call this method from another method in custom code
// For example, [Form]_Load or [Button]_Click
bool recSelected;
string whereClause = string.Empty;
System.Data.DataSet dsCustomerAdapter = Ice.UI.FormFunctions.SearchFunctions.listLookup(this.oTrans, "CustomerAdapter", out recSelected, true, whereClause);
if (recSelected)
{
System.Data.DataRow adapterRow = dsCustomerAdapter.Tables[0].Rows[0];
// Map Search Fields to Application Fields
EpiDataView edvPart = ((EpiDataView)(this.oTrans.EpiDataViews["Part"]));
System.Data.DataRow edvPartRow = edvPart.CurrentDataRow;
if ((edvPartRow != null))
{
edvPartRow.BeginEdit();
edvPartRow["FreeIssueCust_c"] = adapterRow["Name"];
edvPartRow.EndEdit();
}
}
}
private void SetExtendedProperties()
{
// Begin Wizard Added EpiDataView Initialization
EpiDataView edvPart = ((EpiDataView)(this.oTrans.EpiDataViews["Part"]));
EpiDataView edvPartRev = ((EpiDataView)(this.oTrans.EpiDataViews["PartRev"]));
// End Wizard Added EpiDataView Initialization
// Begin Wizard Added Conditional Block
if (edvPartRev.dataView.Table.Columns.Contains("ComplianceChecked_c"))
{
// Begin Wizard Added ExtendedProperty Settings: edvPartRev-ComplianceChecked_c
edvPartRev.dataView.Table.Columns["ComplianceChecked_c"].ExtendedProperties["ReadOnly"] = true;
// End Wizard Added ExtendedProperty Settings: edvPartRev-ComplianceChecked_c
}
if (edvPartRev.dataView.Table.Columns.Contains("EngPeerReview_c"))
{
// Begin Wizard Added ExtendedProperty Settings: edvPartRev-EngPeerReview_c
edvPartRev.dataView.Table.Columns["EngPeerReview_c"].ExtendedProperties["ReadOnly"] = true;
// End Wizard Added ExtendedProperty Settings: edvPartRev-EngPeerReview_c
}
if (edvPartRev.dataView.Table.Columns.Contains("PeerReviewedBy_c"))
{
// Begin Wizard Added ExtendedProperty Settings: edvPartRev-PeerReviewedBy_c
edvPartRev.dataView.Table.Columns["PeerReviewedBy_c"].ExtendedProperties["ReadOnly"] = true;
// End Wizard Added ExtendedProperty Settings: edvPartRev-PeerReviewedBy_c
}
if (edvPartRev.dataView.Table.Columns.Contains("PeerReviewedDate_c"))
{
// Begin Wizard Added ExtendedProperty Settings: edvPartRev-PeerReviewedDate_c
edvPartRev.dataView.Table.Columns["PeerReviewedDate_c"].ExtendedProperties["ReadOnly"] = true;
// End Wizard Added ExtendedProperty Settings: edvPartRev-PeerReviewedDate_c
}
if (edvPartRev.dataView.Table.Columns.Contains("PeerReviewComments_c"))
{
// Begin Wizard Added ExtendedProperty Settings: edvPartRev-PeerReviewComments_c
edvPartRev.dataView.Table.Columns["PeerReviewComments_c"].ExtendedProperties["ReadOnly"] = true;
// End Wizard Added ExtendedProperty Settings: edvPartRev-PeerReviewComments_c
}
// End Wizard Added Conditional Block
}
}
You’re missing the bit that actually does the work. You might try deleting that one line of code, make sure it compiles successfully… and then redo it. I don’t know why but you’re missing this section.
Thanks - yeah that is what I suspected. I have tried deleting that line of code and then recreating rule and selecting update code again and same thing happens. Might try creating a new version of customization and see what happens.
I ended up opening Base form and then creating row rule and it generated code correctly. I then copied the code and updated my customized version and it all works. Thanks for your help!