locked
Approval onload java script RRS feed

  • Question

  • Hi

    I'm not into java and your help wil be appreciated.

    I created 3 attributes (bit) to have the approval of 3 managers on sales order. the default value is 'No' to hide the action menu 'Fullfill Order' untill the value changed to 'Yes' for the 3 attributes.

    I modified exsiting script as below:

    var attribute1 = crmForm.all.custom1.DataValue;

    var attribute2 = crmForm.all.custom2.DataValue;

    var attribute3 = crmForm.all.custom3.DataValue;

     

    if (attribute1 = 0); 

    if (attribute2 = 0); 

    if (attribute3 = 0);

     {

         var FullfillOrder = document.getElementById("_MIcloseOrder3");

         FullfillOrder.style.display="none";

    }

    The hide 'Fullfill Order' is working when useing it alone and I think it's not working because I don't know whichever to use DataValue or value or DataValue.name in my conditions.

     

    Thank you.


    Yataplus
    • Edited by Yataplus Wednesday, April 7, 2010 1:18 PM
    Wednesday, April 7, 2010 9:38 AM

Answers

  • ok,

    Sorry my mistake Try to Check like this

    if((attribute1 ==false) || (attribute2 ==false) || (attribute3 ==false))
    {var FullfillOrder = document.getElementById("_MIcloseOrder3");

    if(FullfillOrder!=null)
         FullfillOrder.style.display="none";}

     


    Mahain
    • Marked as answer by Yataplus Wednesday, April 7, 2010 11:46 AM
    Wednesday, April 7, 2010 11:35 AM
    Moderator

All replies

  • Hello,

    Try to use this script :

    var attribute1 = crmForm.all.custom1.DataValue;

    var attribute2 = crmForm.all.custom2.DataValue;

    var attribute3 = crmForm.all.custom3.DataValue;

     

    if (attribute1 == 0 && attribute2 = =0 && attribute3 == 0 ); 

     {

         var FullfillOrder = document.getElementById("_MIcloseOrder3");

         FullfillOrder.style.display="none";

    }


    Best Regards, Lassaad
    • Proposed as answer by Lassaad.Cabani Wednesday, April 7, 2010 9:48 AM
    Wednesday, April 7, 2010 9:42 AM
  • Change it this way:

     

    if ((attribute1 == 0) && (attribute2 == 0) && (attribute3 == 0)

     {

         var FullfillOrder = document.getElementById("_MIcloseOrder3");

         FullfillOrder.style.display="none";

    }

     

    That may work.

    Wednesday, April 7, 2010 9:43 AM
  • Hi,

    Just check with DataValue

    for example if you want to check attribute1 is selected then check like below

    if(attribute1==true)

    for uncheck

    if (attribute1 = =false) 

    if (attribute2 ==false) 

    if (attribute3 ==false)

     {

         var FullfillOrder = document.getElementById("_MIcloseOrder3");

         FullfillOrder.style.display="none";

    }

     


    Mahain
    Wednesday, April 7, 2010 9:44 AM
    Moderator
  • Thank you all for your help.

     

    I tryed Lassaad and it returned error:

    There was an error with this field's customized event.

    Field:window

    Event:onload

    Error:Object required

     


    Yataplus
    Wednesday, April 7, 2010 10:00 AM
  • what is the name of your attribute?

    The name should be like "new_custom1"

     


    Best Regards, Lassaad
    Wednesday, April 7, 2010 10:06 AM
  • Yes Lassaad it was,

    Also I tryed aziegler Users MedalsUsers MedalsUsers Medalsway and no luck.

    I'm testing Mahender's now.


    Yataplus
    Wednesday, April 7, 2010 10:10 AM
  • If the name of your attribute is new_custom1 your script should be this one:

    var attribute1 = crmForm.all.new_custom1.DataValue;

    var attribute2 = crmForm.all.new_custom2.DataValue;

    var attribute3 = crmForm.all.new_custom3.DataValue;

     

    if (attribute1 == false && attribute2 = =false && attribute3 == false ); 

     {

         var FullfillOrder = document.getElementById("_MIcloseOrder3");

         FullfillOrder.style.display="none";

    }


    Best Regards, Lassaad
    • Proposed as answer by Lassaad.Cabani Wednesday, April 7, 2010 10:19 AM
    Wednesday, April 7, 2010 10:19 AM
  • No luck.
    Yataplus
    Wednesday, April 7, 2010 10:22 AM
  • Hi,

    Could you paste your code here to see ????


    Mahain
    Wednesday, April 7, 2010 10:24 AM
    Moderator
  • I Keep getting this error:

    There was an error with this field's customized event.

    Field:window

    Event:onload

    Error:Object required ?


    Yataplus
    Wednesday, April 7, 2010 10:24 AM
  • Did you test my last script?
    Best Regards, Lassaad
    Wednesday, April 7, 2010 10:26 AM
  • I Keep getting this error:

    There was an error with this field's customized event.

    Field:window

    Event:onload

    Error:Object required ?

    It seems you are not using correct attribute name, please verify attribute names properly .


    Mahain
    Wednesday, April 7, 2010 10:29 AM
    Moderator
  • I did copy past the names of the attributes from the form just to be sure...

    Here is the stangest thing.

    if (attribute1 ==true)
    if (attribute2 ==true)
    if (attribute3 ==true)
     {
         var FullfillOrder = document.getElementById("_MIcloseOrder3");
         FullfillOrder.style.display="none";
    }

    it's working like charm but when I use  

    if (attribute1 ==false)
    if (attribute2 ==false)
    if (attribute3 ==false)
     {
         var FullfillOrder = document.getElementById("_MIcloseOrder3");
         FullfillOrder.style.display="none";
    }

    it's through the above error?

    I checked the spelling many times :)


    Yataplus
    Wednesday, April 7, 2010 10:45 AM
  • Hi,

    Change your code like this

    if (attribute1 ==false)
    if (attribute2 ==false)
    if (attribute3 ==false)
     {
         var FullfillOrder = document.getElementById("_MIcloseOrder3");

    if(FullfillOrder!=null)
         FullfillOrder.style.display="none";
    }


    Mahain
    Wednesday, April 7, 2010 10:57 AM
    Moderator
  • Mahain thank you..I feel its going to be solved soon.

    Now it's working but the fullfill order shows after changeing the attribute1 to Yes.

    The goal is to hide it untill the all 3 attributes become Yes.

     

    Thank you again


    Yataplus
    Wednesday, April 7, 2010 11:07 AM
  • You need to connect the if-statements so you get one.

     

    When you write "if (statement) { do.something}", then it's only dependent on "statement".

    If you have two statements, you need to do this:  "if ((statement1) && (statement2)) { do.something}

     

    I'm sure you're just having basic problems with javascript syntax. Try this: http://java2s.com/  and read the Javascript tutorial on IF-statements. I'm sure you'll succeed.

    Wednesday, April 7, 2010 11:11 AM
  • Ok,

    Try to Check like this

    if((attribute1 ==true) && (attribute2 ==true) && (attribute3 ==true))
    {var FullfillOrder = document.getElementById("_MIcloseOrder3");

    if(FullfillOrder!=null)
         FullfillOrder.style.display="none";

    }


    Mahain
    Wednesday, April 7, 2010 11:11 AM
    Moderator
  • Not working,

    But when I use

    if (attribute1 ==false);
    if (attribute2 ==false);
    if (attribute3 ==false)
     {
         var FullfillOrder = document.getElementById("_MIcloseOrder3");

    if(FullfillOrder!=null)
         FullfillOrder.style.display="none";
    }

    It work for attribute1 and attribute2 but when I add ; after attribute3 fullfill order stay hiden.


    Yataplus
    Wednesday, April 7, 2010 11:26 AM
  • ok,

    Sorry my mistake Try to Check like this

    if((attribute1 ==false) || (attribute2 ==false) || (attribute3 ==false))
    {var FullfillOrder = document.getElementById("_MIcloseOrder3");

    if(FullfillOrder!=null)
         FullfillOrder.style.display="none";}

     


    Mahain
    • Marked as answer by Yataplus Wednesday, April 7, 2010 11:46 AM
    Wednesday, April 7, 2010 11:35 AM
    Moderator
  • Mahain you are the man.

     

    Worked like charm :)

    Thank you for your prompt replies and support


    Yataplus
    Wednesday, April 7, 2010 11:46 AM
  • Thank you aziegler for your replaies.

    and yes I'll do. actually that is very supportive of you :)


    Yataplus
    Wednesday, April 7, 2010 11:56 AM
  • Thank you Laassad.

    You was the 1st to reply :)


    Yataplus
    Wednesday, April 7, 2010 11:58 AM