Scripting

Expand all | Collapse all

Created a simple script to pull a CI_Item UDF into

Kevin Moyes

Kevin Moyes06-01-2017 12:46

  • 1.  Created a simple script to pull a CI_Item UDF into

    Posted 06-01-2017 11:46
      |   view attached
    Created a simple script to pull a CI_Item UDF into a BM_ProductionHeader UDF in order to show the value on the production entry screen. The script is set to run post validate on BillNo in Production Header. Works beautifully n v2016 standard on my local machine but does't return the value in v2014 Premium on hte client setup. The original script that I used as my starting point was written in v2014 for BOM so I didn't expect to have an issue with the non-framework version. The script finds the Bill Number as an Item just fine, but is not retrieving the UDF value from CI_Item. Any ideas on what needs to be modified for it to work in the v2014 client environment? @AlnoorCassim @NicoleRonchetti Attached is a screenshot of the trace window . Here is the script syntax: sItemCode = """" : sConversion = """" sItemCode = value r=oScript.DebugPrint(""sItemCode "" & sItemCode) If IsObject(oItem) = False Then Set oItem = oSession.AsObject(oSession.GetObject(""CI_ItemCode_svc"")) End If retFind = oItem.Find(sItemCode) If retFind = 1 Then r=oScript.DebugPrint(""Found "" & sItemCode) 'set the trace window retVal= oitem.GetValue(""UDF_CONVERSION$"",sConversion) r=oScript.DebugPrint(""Read sConversion "" & sConversion) retVal= oBusObj.SetValue(""UDF_BM_PROD_CONVERSION$"", sConversion) r=oScript.DebugPrint(""Write sConversion"" & sConversion) else r=oScript.DebugPrint(""Did NOT Find "" & sItem & "" sConversion"" & sConversion) 'set the trace window r=oScript.DebugPrint(""No Value written to Screen"") End if


  • 2.  RE: Created a simple script to pull a CI_Item UDF into

    Posted 06-01-2017 12:18
    On the DebugPrint for the SetValue you want to include your retVal in there so you can see if it's a 1 or 0. So if retVal = 0 then show the oBusObj.LastErrorMsg in a new DebugPrint


  • 3.  RE: Created a simple script to pull a CI_Item UDF into

    Posted 06-01-2017 12:39
      |   view attached
    @AlnoorCassim added this: retVal= oItem.GetValue(""UDF_CONVERSION$"",sConversion) If retVal = 0 then r=oScript.DebugPrint(oBusObj.LastErrorMsg) else r=oScript.DebugPrint(""retVal<>0"") End If r=oScript.DebugPrint(""Read CI_Item sConversion "" & sConversion) retVal= oBusObj.SetValue(""UDF_BM_PROD_CONVERSION$"", sConversion) r=oScript.DebugPrint(""Write BM Prod sConversion"" & sConversion) I get the ""retVal<>0"" message in the debug


  • 4.  RE: Created a simple script to pull a CI_Item UDF into

    Posted 06-01-2017 12:42
    Same result on the oItem.GetVal and the oBusObj.SetVal


  • 5.  RE: Created a simple script to pull a CI_Item UDF into

    Posted 06-01-2017 12:43
    Your Read debug result is showing the value is blank.


  • 6.  RE: Created a simple script to pull a CI_Item UDF into

    Posted 06-01-2017 12:44
    @KevinMoyes yes, I know. That is the problem. I don't know why it is blank. It reads and writes just fine in v2016 but on the client system doesn't seem to read it.


  • 7.  RE: Created a simple script to pull a CI_Item UDF into

    Posted 06-01-2017 12:46
    String vs number? Named differently?


  • 8.  RE: Created a simple script to pull a CI_Item UDF into

    Posted 06-01-2017 12:49
    both UDFs are setup as string and I verified the UDF name in the client system.


  • 9.  RE: Created a simple script to pull a CI_Item UDF into

    Posted 06-01-2017 12:50
    Can you grab and display something else, like the item description?


  • 10.  RE: Created a simple script to pull a CI_Item UDF into

    Posted 06-01-2017 12:52
    My gut reaction is that some other PostValidation (probably not user-defined) is wiping out your value. I'd be curious if a PreValidation actually works...


  • 11.  RE: Created a simple script to pull a CI_Item UDF into

    Posted 06-01-2017 12:54
    @KevinMoyes same results trying to pull product line. @SteveIwanowski same results on pre-validate


  • 12.  RE: Created a simple script to pull a CI_Item UDF into

    Posted 06-01-2017 13:02
    Seems like something wrong with your oItem. `oItem = oSession.GetObject(""CI_ItemCode_svc"") if oItem <> 0 then Set oItem = oSession.AsObject(oItem) else retVal = oSession.AsObject(oSession.UI).MessageBox("""", ""Access to CI_ItemCode_svc is required for the ... script to work."") exit sub end if`


  • 13.  RE: Created a simple script to pull a CI_Item UDF into

    Posted 06-01-2017 13:04
    DFDM CI_Item for 10001 and verify the UDF has a value...


  • 14.  RE: Created a simple script to pull a CI_Item UDF into

    Posted 06-01-2017 13:14
    @KevinMoyes it finds my item on the retFind=oItem.Find. I've tried this method as well as the GetChildHandle method and both return the item value but don't return the value on retVal = oItem.GetValue. Again...this works in 2016 Standard but fails to return a value in 2014 Premium. And yes, I have verified that 10001 has a UDF value.


  • 15.  RE: Created a simple script to pull a CI_Item UDF into

    Posted 06-01-2017 13:22
    *shrugs* I do scripting on Premium all the time and it is not different than Standard for event scripts.


  • 16.  RE: Created a simple script to pull a CI_Item UDF into

    Posted 06-01-2017 13:24
    Yeah...I loaded 4 scripts last night and this is the only one that doesn't want to play nice.


  • 17.  RE: Created a simple script to pull a CI_Item UDF into

    Posted 06-01-2017 13:28
    With a header script I sometimes turn it into a button to troubleshoot more easily (without having to recompile and reopen the screen for every new test).


  • 18.  RE: Created a simple script to pull a CI_Item UDF into

    Posted 06-01-2017 13:42
    Grasping at straws, can you try hitting the Update button on CI _Item in UDF Maintenance? Can we see a screenshot of DSD's DFD&M (http://www.dsdinc.com/enhancement/premium-data-file-display-maintenance/). In a pinch, you could use ODBC to pull in the value for right now.


  • 19.  RE: Created a simple script to pull a CI_Item UDF into

    Posted 06-01-2017 14:03
    banging my head against a wall...the UDF on the client system was numeric...Helps to verify string/numeric on the CORRECT UDF. Thanks for all of the help gentlemen!!!