SetValue for ItemCodeDesc$ creating extended descriptions...

SOLVED

I have a button script running in Item Maintenance which is querying extended description text successfully, but the SetValue doesn't work (in v2017 and v2020).  I'd expect the business object to automatically create the extended description key / record automatically (as happens with VI imports) but that isn't happening.

retVal = oBusObj.SetValue("ItemCodeDesc$",sExtendedDescText)

Is there a trick to get this working?

  • 0

    To clarify, the SetValue does set the ItemCodeDesc, but the extended text is truncated.  I am absolutely certain the script has the correct value loaded because I put in a pop-up to display the value...

    Yet what gets set in the item is cut short.

  • 0

    This is a script that takes the value in a PDF in Purchase Order Entry and writes it back to the Extended Description table. Maybe it will give you some ideas:

    retVal=0
    itmCode=""
    ExtKey=""
    oItmSvc=0
    Notes=""
    oExtItem=""
    ExtDes=""

    retVal=oBusObj.GetValue("ItemCode$",itmCode)
    retVal=oBusObj.GetValue("ExtendedDescriptionKey$",ExtKey)
    oItmSvc = oBusObj.GetChildHandle("ItemCode")
    Set oExtItem = oSession.AsObject(oSession.GetObject("CI_ExtendedDescription_bus"))
    set oItmSvc=oSession.AsObject(oItmSvc)
    retVal=oItmSvc.Find(itmCode)
    retVal=oItmSvc.GetValue("UDF_PURCHASE_ORDER_NOTES$",Notes)
    retVal=oExtItem.Find(ExtKey)
    retVal=oExtItem.Getvalue("ExtendedDescriptionText$",ExtDes)
    If Notes <>"" then retVal=oBusObj.SetValue("ExtendedDescriptionText$",Notes)

  • 0

    Where are you launching this script from?

  • 0 in reply to BigLouie

    Thanks BL, but I want Sage to create a new extended description entry, not update an existing extended description.  If I have to do that manually I can probably figure it out, but I don't think I should have to...

  • 0 in reply to Sage100User

    It's a button script.  Customer wants a "Copy From" function, with only specific fields copied (as a replacement for the Sage "Copy From" button, which brings in many fields they don't want in the new item)... with a button click to create a BoM.

    I open the "copy from" item, getting the extended description just fine, but the SetValue in the new item doesn't include the full extended text.

  • +1 in reply to Kevin M
    verified answer

    What version are you on?

    On my 2018 install, i just tested using the item maintenance's bus object's SetValue on the description and got a return value of -1.

    i then checked the LastErrorMsg and got this.

    I then tried to Write the changes but found the extended description was not created. A little more digging and i found that when the UI is present, it expects a value in a variable local to the UI object called HdrExtDescriptionText when writing the description back. When you use oBusObj.SetValue on the ItemCodeDesc, it does not seem to set the value into the HdrExtDescriptionText variable. So if the UI is present, such as the case since your button is in Item Maintenance, do your normal routine of using SetValue on the ItemCodeDesc and then check the length and if greater than 30, use oUIObj.SetVar "HdrExtDescriptionText$", sExtendedDescText

    EDIT:

    Just following up that it is indeed only an issue when the UI is present. I reset the description and then used SYZCON to mimic changing the description through BOI without the UI and i only had to use SetValue on the ItemCodeDesc.

  • 0 in reply to David Speck

    That is awesome David!  I would have never figured that out. 

    I still say this should be done by the business object, but simply adding your line made it work for my v2020 test.  The customer is still on v2017, but planning on an upgrade in a few months so even if it doesn't work for them now it's not a long wait until it will.

    Thanks!

  • 0 in reply to Kevin M

    I agree, the business object should be handling that. Assuming nothing has changed much regarding the extended description once CI and IM made it to framework, i would expect this to work on prior versions. I doubt 2017 would not work but who knows until you try it.

  • 0 in reply to David Speck

    I have related issue. I have no UI present and when I set the ItemCodeDesc$ with a string longer than 30 char, then it will automatically create/update the Extended Description. But if I already have an Ext.Desc and set the Description with a value with 30 char or less, then it updates the description, but doesn't delete the Extended one. Is there an easy way (short of manually removing the Ext.DescKey from CI_Item and the ExtDesc from the ExtDesc table?

  • 0 in reply to BillyVanilli

    Which object are you working with? 

    If it has a property for the extended description business object, then you can grab the current extended description key from your record after test that the new description is less than or equal to 30 characters and then use the extended description business object's Delete method with the extended description key you grabbed earlier.  You may need to grab said key before you write your new description though just in case the business object sets the key to "0000000000".  You should check whether or not the business object does set the extended description key to "0000000000" and if is doesn't, use SetValueNoValidate to set it, either hardcode it to use "0000000000" or use the extended description business object's GetDefaultExtendedDescriptionKey() method to return whatever Sage 100 determines to be the default extended description key, which will be more flexible in the event Sage decides to change the default key in the future.