CA Service Management

  • 1.  Set Multiple Field Values Using ca_fdSetTextFieldValue

    Posted Sep 22, 2014 10:34 AM

    I have a catalog form that allows the user to select a server. Once a server is selected, the form runs a series of reports to populate fields with the current values for the amount of memory, processing cores, and storage. Next to each of these fields is a spinner field that allows the user to select the desired amount of resources for each type. In other words, they can select more or less memory, more or fewer cores, etc... These spinners should be initialized to the current value upon server selection.

     

    Here's my problem: ca_fdSetTextFieldValue will only set the value of the first spinner and all subsequent code is ignored. It's as if the javascript engine hits a terminating error and quits out silently.

     

    Is there a more appropriate way to set the value of a spinner field?

     

    Here's an example:

    {
        Display_Current_Value : function ()
        { 
            var server_name = {value:ca_fdGetSelectedOptionValues(ca_fd.formId,'server_name')};
            ca_reportQuery('Physical-Memory-BCBS',{"Server_ID_BCBS":server_name.value},ca_fd.js.onSuccessMemory,ca_fd.js.onFailMemory);
        },
    
        onSuccessMemory : function (result)
        {
            if (result.length == 1)
            {
                var memory = Number(result[0].physical_memory);
                var cores = Number(result[0].cores);
                
                ca_fdSetTextFieldValue(ca_fd.formId,'current_memory',memory);     // Text field
                ca_fdSetTextFieldValue(ca_fd.formId,'desired_memory',memory);     // Spinner
                
                ca_fdSetTextFieldValue(ca_fd.formId,'current_cores',cores);        // Text field
                ca_fdSetTextFieldValue(ca_fd.formId,'desired_cores',cores);        // Spinner
            }
        },
    
        onFailMemory : function ()
        {
            ca_fdSetTextFieldValue(ca_fd.formId,'current_memory','No Memory Populated');
            ca_fdSetTextFieldValue(ca_fd.formId,'current_core_count','No Core Count Populated');
        }
    }
    

     

    NOTE: In this example, the first text field value is set and the first spinner is initialized. None of the code below line 16 is processed. If I rearrange the code such that I swap lines 16 and 18, then the two text fields are populated and the first spinner is initialized but line 19 is never executed.



  • 2.  Re: Set Multiple Field Values Using ca_fdSetTextFieldValue

    Posted Sep 23, 2014 07:58 PM

    Perhaps change your Spinner to a Slider and use ca_fdSetSliderValue.



  • 3.  Re: Set Multiple Field Values Using ca_fdSetTextFieldValue

    Posted Sep 23, 2014 08:49 PM

    I haven't tried to use the predefined 'ca_fdSetTextFieldValue' method for spinner fields, as there is no predefined methods for the spinner I instead just use jQuery to set the value (as this is similar the predefined methods if you look in the code anyway).

    e.g. '$("[_id=desired_memory]").val(memory);

     

    Or to get the spinner field value:

    e.g. 'var spinValue = parseInt($("[_id=desired_memory]").val());'



  • 4.  Re: Set Multiple Field Values Using ca_fdSetTextFieldValue

    Posted Oct 23, 2014 08:02 AM

    How/Where do you include the JQuery libraries so that they can be used on your Service Catalog forms?