Sage 100

 View Only
  • 1.  In need of a Custom Office script to require a Pri

    Posted 10-27-2014 20:34
      |   view attached
    In need of a Custom Office script to require a Primary Contact Code but allow users to create a new code on-the-fly and then assign it. When using Advanced Field Settings to require this field, the user is sent through a loop of ""the contact code is required"". I read in old KB that we could do this with a script, so not knowing much about scripting, I copied syntax from various places and came up with the attached script, but it will still not allow me to create the code and then assign it. Any thoughts?

    Attachment(s)

    zip
    Required_Contact.zip   305 B 1 version


  • 2.  RE: In need of a Custom Office script to require a Pri

    Posted 10-27-2014 23:15
    What version of MAS and is it 90 or 200? I assume your script is set for the Pre-Write event Your script is fine but what you're trying to accomplish is not conducive to scripting. When you click the Primary Contact hyperlink (which is the same as clicking the Contacts button from the dropdown in to the top right), MAS itself saves off the customer record (or save off vendor record if you clicked Primary Vendor). But this save triggers your script that prevents the save of the record. Hope you like pickles. In Item Maintenance, a similar problem exists when trying to use a script to enforce a primary vendor for the item. However through storage variables and multiple scripts we can deal with the issue. But here you can only deal with it in a half arsed way. What the below buys you is the ability to key in something in the Primary Contact field THEN you can click the Primary Contact hyperlink or the Contacts button in top right to bring up Customer Contact Maint. IOW you can't just first click that blue Primary Contact link (you'll have the same prob). You have to key in the contact code first. Hope that made sense. 1) Create a column Pre-Validatate script on ContactCode that does: retVal = oScript.SetStorageVar(""SV_NewContact"", ""Y"") 2) Your current Pre-Write script gets conditionalized to run like this: WasNewContactSet = """" retVal = oScript.GetStorageVar(""SV_NewContact"", ""WasNewContactSet"") If WasNewContactSet <> ""Y"" and primarycontact = """" Then ' show msg the contact code is required End If 3) Optionally have a Post-Read script to clear storage var for next new customer: retVal = oScript.SetStorageVar(""SV_NewContact"", ""N"")


  • 3.  RE: In need of a Custom Office script to require a Pri

    Posted 10-28-2014 07:32
    Thank you, Alnoor. I will try this later on. I saw that I could set a ""fake"" default value into that field as well, but if the user tries to accept a new customer record, it throws an error, so I wanted to see if we could do scripting instead.


  • 4.  RE: In need of a Custom Office script to require a Pri

    Posted 10-31-2014 19:32
    OK - I'm dense when it comes to scripting - I'm not following if I was supposed to copy yours or merge yours with mine. But I have tried different configurations and cannot get out of the ""contact code is required"" loop at all. This is what I have now: primarycontact = """" wasnewcontact = """" retval = oscript.getstoragevar(""sv_newcontaact"", ""wasnewcontactset"") if wasnewcontactset <> ""y"" and primarycontact="""" then oscript.seterror(""the primary contact code is required"") end if I'm a little embarrassed to ask, but what am I missing?


  • 5.  RE: In need of a Custom Office script to require a Pri

    Posted 10-31-2014 19:36
    Hey aren't you're supposed to be trick o treating with your lil guy :) Will PM you.