Form ID

sabzamsabzam Member Posts: 1,149
Hi all, does anyone know if i can get form id from another form??

my problem is that on the OnOpenForm tirgger of the Item List there is a set of filters being activated, now i want to skip those if the user uses the lookup button on one specific form. i thought i can get around it if i know the objectid of which object is calling ItemList.

Or maybe someone can show me some light to another solution to this problem?

Thanks

Comments

  • David_SingletonDavid_Singleton Member Posts: 5,479
    sabzam wrote:
    Hi all, does anyone know if i can get form id from another form??

    my problem is that on the OnOpenForm tirgger of the Item List there is a set of filters being activated, now i want to skip those if the user uses the lookup button on one specific form. i thought i can get around it if i know the objectid of which object is calling ItemList.

    Or maybe someone can show me some light to another solution to this problem?

    Thanks

    I do this quite often, especially to set the form to non editable if the form is being used as a lookup (eg. forms like Country, Sales person etc.) Just add this code in the form
    Form - OnOpenForm()
    IF CurrForm.LOOKUPMODE THEN
      CurrForm.EDITABLE(FALSE);
    
    David Singleton
  • sabzamsabzam Member Posts: 1,149
    thanks for the quick reply, but doesnt that become applicable for every form its uses ItemList as a lookup form instead of that one specific form i need?
  • David_SingletonDavid_Singleton Member Posts: 5,479
    sabzam wrote:
    thanks for the quick reply, but doesnt that become applicable for every form its uses ItemList as a lookup form instead of that one specific form i need?

    In that case yes, so instead of explaining HOW you want to do this, why don't you explain WHAT you want to do.
    David Singleton
  • Alex_ChowAlex_Chow Member Posts: 5,063
    sabzam wrote:
    Hi all, does anyone know if i can get form id from another form??

    my problem is that on the OnOpenForm tirgger of the Item List there is a set of filters being activated, now i want to skip those if the user uses the lookup button on one specific form. i thought i can get around it if i know the objectid of which object is calling ItemList.

    Or maybe someone can show me some light to another solution to this problem?

    Thanks

    We've had clients with similar requests. What we did is to put the code on the OnLookup trigger of the form and set the filter beforehand.
            //set your filters here
            ItemForm.SETTABLEVIEW(ItemRec);
            ItemForm.LOOKUPMODE := TRUE;
            IF ItemForm.RUNMODAL = ACTION::LookupOK THEN BEGIN
              (blah blah blah)
    
  • sabzamsabzam Member Posts: 1,149
    Ok let me explain better than before then,

    I have a form, where you have to choose an item, the textfield is linked to the itemlist form. now the itemlist hase some code running on the openform trigger which i want to skip if the lookup is made from this specific form but ran if made from the rest of the objects.
  • David_SingletonDavid_Singleton Member Posts: 5,479
    sabzam wrote:
    Ok let me explain better than before then,

    I have a form, where you have to choose an item, the textfield is linked to the itemlist form. now the itemlist hase some code running on the openform trigger which i want to skip if the lookup is made from this specific form but ran if made from the rest of the objects.


    yes but what is it you need to do? Why does the code run in one case and not in another? What is the business reason for this.
    David Singleton
  • klavinklavin Member Posts: 117
    I'm not sure the purpose of this either, but an idea of how to do it would be below. Theres a bunch of ways to play with it...But I agree with David there may be a better way of going about it depending on the business reason.

    Couldn't you just manuall write the OnLookup code of the control, and pass information to a function on the new form?

    E.G.
    (Just making this up)
    Definite ItemList
    No. - OnLookup(VAR Text : Text[1024];) : Boolean
    CLEAR(ItemList);
    ItemList.MyFunction(TRUE);
    //Or play with CurrForm.OBJECTID(FALSE), maybe have to do COPYSTR for just the number section
    //Remember doesn't return the object ID while run in design mode...
    IF ItemList.RUNMODAL() = ACTION::LookupOK THEN BEGIN
        //Assign whatever you're assigning
    END;
    

    and on the 2nd form create a function that either takes that ObjectID, or just has a global variable
    MyFunction(boolean RunFromForm)
    IgnoreFilters := RunFromForm;
    


    Then OnOpenForm around your filters..
    IF NOT IgnoreFilters THEN BEGIN
    
    END;
    
    -Lavin
    "Profanity is the one language all programmers know best."
  • sabzamsabzam Member Posts: 1,149
    the code that i dont want to run is setting some filter groups whilst from this specific form i want to set different filters. my desired filter is simply not to display blocked items, whilst the other filter groups, set filters according to userid. now the client just for this specific form wants to display only unblocked items for all users. dont know if im being specific enough.
Sign In or Register to comment.