Scripting

Expand all | Collapse all

I am trying to hide or show a custom text object t

Amber Prayfrock

Amber Prayfrock05-16-2018 08:16

  • 1.  I am trying to hide or show a custom text object t

    Posted 05-09-2018 15:24
    I am trying to hide or show a custom text object that I added to the Sales Order Entry screen but my script only works with a BT_Link object and not a Fonted_Text object. From reading Alnoor's manual, I know that I can't control any field called ""Fonted_Text_UDF"" since that is a generic name associated with all UDF titles, but my objects have a unique name of ""Fonted_Text_1"" and ""Fonted_Text_2"" so shouldn't this script work for me...in theory?


  • 2.  RE: I am trying to hide or show a custom text object t

    Posted 05-09-2018 15:43
    No, text is drawn differently by provideX compared to a control like a multi_line or button. If the text is a caption for a udf, you might be able to hide the text and the udf by using the group variable for the udf otherwise you will have to add a multi_line udf for the text you want and set it to locked and borderless so it looks like a field caption. If you use the multi_line udf for your caption, you shouldn't have any problem doing this from a table or ui script. If you want to use the group variable, you will need a script on the post load event of the panel where your udf and its caption is. All this script needs to do is the following. _________________________________________________________________ oScript.Execute ""%UDF_your_udf_name.grp$=UDF_your_udf_name.grp$"" _________________________________________________________________ Now in your table script you have to check if %UDF_your_udf_name.grp$ is not blank before you try to use it. So something like the following. Substitute Hide with Show, Enable, or Disable as needed. _________________________________________________________________ If Len(oScript.Evaluate(""%UDF_your_udf_name.grp$"")) > 1 then oScript.Execute ""Call """"*wingrp;Hide"""", %UDF_your_udf_name.grp$"" _________________________________________________________________


  • 3.  RE: I am trying to hide or show a custom text object t

    Posted 05-09-2018 20:06
    Thank you for the quick response and script, David, but I'm not understanding it. Maybe it's late but I'm trying to play with it and it's not even passing syntax checking. I wouldn't mind using just a basic multiline field as you suggested but I need to be able to make the text bold and red. It's to show that a customer is on credit hold when a new order is initiated from CRM, since the standard warning window does not pop up. So I need to be able to design something that stands out (customer does not want a one-time pop-up).


  • 4.  RE: I am trying to hide or show a custom text object t

    Posted 05-09-2018 20:32
    I just realized I made a typo in the table script in the above post and that is why it was failing syntax check. I have corrected it and it should work now. Keep in mind that this approach will only work if the fonted text you are trying to manipulate was added automatically when you added a udf to the panel. If you just added fonted text by itself, this will not work. The only reason this works is because I have found looking through data dumps that nomads creates the variable ending with the .grp$ suffix for each udf. Somehow it is grouping the fonted text and the udf control together and therefore it can be manipulated with the wingrp utility. This variable however is local to the UI object and under normal circumstances, a table script will never know the contents of the variable and so this would not work. That is why the UI script first copies the local variable into a global variable of the same name. The % prefix identifies a variable as global. The global variable should have a value when the table script is fired and it is the content of that variable that is passed to the wingrp utility. This is really deep into the provideX side of things but thought I would share it.


  • 5.  RE: I am trying to hide or show a custom text object t

    Posted 05-09-2018 20:36
    Beautiful - I will try this tomorrow. Can I do this then using my variable? If Len(oScript.Evaluate(""%UDF_your_udf_name.grp$"")) > 1 and sCreditHold = ""Y"" then oScript.Execute ""Call """"*wingrp;Hide"""", %UDF_your_udf_name.grp$


  • 6.  RE: I am trying to hide or show a custom text object t

    Posted 05-09-2018 20:41
    I think you might have your logic inverted. If they are on credit hold, isn't that when you want the warning to be displayed? You can get creative with this and have an IF..then.else block above this where you check for a condition and set a variable to hold the value of the state (Hide, Show, Enable, Disable) then use the line I posted but substitute Hide with what's inside the following brackets ["" & sYourVariableName & ""].


  • 7.  RE: I am trying to hide or show a custom text object t

    Posted 05-09-2018 20:47
    Also keep in mind that this approach works fine for static text that will never change but if you ever find yourself wanting to be able to change the message of your warning dynamically, you will be better off using a locked and borderless multi_line as they are easier to manipulate the contents and state.


  • 8.  RE: I am trying to hide or show a custom text object t

    Posted 05-14-2018 18:35
    Hi David - I just wanted to say thank you for your time in responding and for offering some suggestions, I wasn't able to figure out how to properly implement your ""grp"" script...I worked on it here and there over the weekend and it just wasn't clicking with me how it was to be used. But I did consider using the borderless ML UDF and found a Sage City posting that talked about setting background and text colors (which you responded to as well) so I used the text color portion to set and display red text. I tried the background color, which worked, BUT...the field stayed colored after accepting/canceling out of the sales order and I couldn't figure out how to get that part of the script to ""reset"". If you have any ideas. please let me know. I'd like to know for future reference since it's a cool feature. 'Reset Variables sDivision = """" : sCustomer = """" oCust = """" : sCreditHold = """" : retval = 0 retVal = oBusObj.GetValue(""ARDivisionNo$"", sDivision) retVal = oBusObj.GetValue(""CustomerNo$"", sCustomer) 'Set Customer Maintenance Object and Primary Key set oCust = oSession.AsObject(oSession.GetObject(""AR_Customer_bus"")) retVal = oCust.SetKeyValue(""ARDivisionNo$"", sDivision) retVal = oCust.SetKeyValue(""CustomerNo$"", sCustomer) retVal = oCust.Find() if Not(IsObject(oUIObj)) Then Set oUIObj = oSession.AsObject(oScript.UIObj) end if if retval = 1 then retval = oCust.GetValue(""CreditHold$"", sCreditHold) if sCreditHold = ""Y"" then 'retVal = oUIObj.SetControlProperty(""UDF_COCH_DISPLAY"", ""BackColour"", ""LIGHT RED"") retval = oBusObj.SetValue(""UDF_COCH_DISPLAY$"", "" CUSTOMER ON CREDIT HOLD"") retVal = oUIObj.SetControlProperty(""UDF_COCH_DISPLAY"", ""TextColour"", ""RGB: 255 0 0"") end if end if


  • 9.  RE: I am trying to hide or show a custom text object t

    Posted 05-15-2018 13:22
    You shouldn't need to get a handle to the AR_Customer_bus object, there is a numeric property available to the sales order business object called CreditHold so all you need to do is compare if oBusObj.CreditHold = 1 then the customer is on credit hold. Also, if you are just wanting to display a message in a UDF and don't want it to trigger the prompt to save the record, as long as the UI object is available, you can use oUIObj.SetControlProperty ""UDF_Your_UDF_Name"", ""Value$"", ""Your Message"" Also, when using the SetControlProperty method, you should make sure that you add a $ to the end of the property name if you are setting a string value, don't add the $ when setting a numeric value. In the above example, I want to set a string value into the Value property of the control, since i'm setting a string value i use ""Value$"". If i was wanting to enable/disable the control using this method, i would use ""Enabled"" and use 1 for enabled and 0 for disabled. Unfortunately, there isn't an event for when a record is released so there isn't a way for you to reset your UDF on that alone. You would have to script additional events to reset it, for example, you would use the Post Read, Post Write, and Post Delete events to handle most events but in the event the user uses the Accept (with no changes to be saved) or Cancel button then you have no way to reset your UDF. One way around this is to use faux Accept and Cancel buttons. Each button would do you routine to reset the UDF and then invoke the real button.


  • 10.  RE: I am trying to hide or show a custom text object t

    Posted 05-15-2018 13:31
    Thank you, David. I will test out the ""CreditHold"" bus obj to understand how that works.


  • 11.  RE: I am trying to hide or show a custom text object t

    Posted 05-15-2018 13:35
    Just to clarify, CreditHold is a property (not a bus obj) of the oBusObj object handle available when running a script on the SO_SalesOrderHeader table.


  • 12.  RE: I am trying to hide or show a custom text object t

    Posted 05-15-2018 15:57
    Also, for some reason, the grp variables are not initialized in Sales Order Entry, i guess i got lucky when i found them during a project involving the Alias Item Maintenance panel. You could always create your own grp variables and assign your custom text messages to any number of grps. See the attached scripts for examples of this. See the attached images on proper set up. Use Customizer to determine placement, see attached image for example. Make sure to attach the Set_Credit_Hold_Warning script to the panel where you get the placement value from, in my example, the script is attached to the pHeader panel because that is where i want it displayed.

    Attachment(s)



  • 13.  RE: I am trying to hide or show a custom text object t

    Posted 05-16-2018 08:16
    Thank you! I am excited to test these out!!