BPM Data Directive

Hello Folks,

I need some help with this issue. Since I need to lock QTY / Date in PO Entry, I have created a Data Directive for PORel (In-Transaction), and added the code below:

/* Set the Lock Date checkbox
and/or the Lock Qty checkbox when a new PORel is created.
The Lock Date and Lock Qty checkbox values are stored in the COMXref table.
COMxref.foreignKey1 = Lock Date
COMxref.foreignKey2 = Lock Qty */
bool foundComxRefRecord = false;
string setLockDate = "No";
string setLockQty = "Yes";
Erp.Tables.COMXref COMXref;
foreach (var ttPORel_iterator in (from ttPORel_Row in ttPORel
                                  where string.Equals(ttPORel_Row.RowMod, IceRow.ROWSTATE_ADDED, StringComparison.OrdinalIgnoreCase)
                                  select ttPORel_Row))
    var ttPORelRow = ttPORel_iterator;
    COMXref = (from COMXref_Row in Db.COMXref
               where string.Compare(COMXref_Row.Company, ttPORelRow.Company, true) == 0
               && string.Compare(COMXref_Row.File, "PORel_Mapping", true) == 0
               && COMXref_Row.Key1 == System.Convert.ToString(ttPORelRow.PONum)
               && COMXref_Row.Key2 == System.Convert.ToString(ttPORelRow.POLine)
               && COMXref_Row.Key3 == System.Convert.ToString(ttPORelRow.PORelNum)
               select COMXref_Row).FirstOrDefault();
    if (COMXref != null)
        COMXref.foreignKey1 = setLockDate;
        COMXref.foreignKey2 = setLockQty;
        foundComxRefRecord = true;
        Db.Release(ref COMXref);
    if (!foundComxRefRecord)
        COMXref = new Erp.Tables.COMXref();
        COMXref.Company = ttPORelRow.Company;
        COMXref.File = "PORel_Mapping";
        COMXref.Key1 = System.Convert.ToString(ttPORelRow.PONum);
        COMXref.Key2 = System.Convert.ToString(ttPORelRow.POLine);
        COMXref.Key3 = System.Convert.ToString(ttPORelRow.PORelNum);
        COMXref.foreignKey1 = setLockDate;
        COMXref.foreignKey2 = setLockQty;
Now, the code compiles flawless, but when trying to add / modify a line or release on an open PO, I get the following error: "LINQ to Entities does not recognize the method 'System.String ToString(Int32)' method, and this method cannot be translated into a store expression."

I have tried to replace the System.String ToString(Int32)' method for the SqlFunctions.StringConvert method instead of just ToString (which cannot be converted into SQL), but then I get a compilation error: "Error CS0103: The name 'SqlFunctions' does not exist in the current context [InTranTrigger.cs(159,39)]"

I will appreciate if somebody can shed some light on this issue.
Daniel Dell'Aquila