• Resolved chadtesting

    (@chadtesting)


    Hi CodePeople, in an earlier thread you wrote the following:

    If you want get a row based on the option selected in a DropDown field, I recommend you to use a RecordSet DS field to read the CSV file, and then, you can walk through the records as part of the equation.

    For example, assuming that CSV file includes the columns: column_a, column_b, and column_c, and you want get the record whose column_b matchs with the option selected in the DropDown field fieldname1, and the Recordset DS field is the fieldname2, the equation would be similar to:

    (function(){
        var records = fieldname2, row;
    
        foreach(var i in records)
        {
            if(records[i]['column_b'] == fieldname1)
            {
                row = records[i];
                break;
            }
        }
    
        /** USE THE row VARIABLE IN THE EQUATION **/
    }
    })()

    Now the dropdown field I’m using is also a DS field. In this case, would I replace the DS field with the DS Recordset, or would this require the following elements..

    DS Dropdown (fieldname1)
    DS Recordset (fieldname2)
    Calculated Field (let’s say fieldname3) to insert the code above?

    Thanks for clarifying.

Viewing 14 replies - 1 through 14 (of 14 total)
  • Plugin Author codepeople

    (@codepeople)

    Hello,

    You are merging different concepts, the piece of code in your ticket is for accessing to the recods in a recordset field through an equation.

    About the DropDown DS fields the process is the same, the DropDown DS fields are similar to the DropDown fields, the unique difference is the source of data to populate the field, but if you want to get the record (or row) corresponding to the choice selected in the DropDown DS field, the equation would be the same.

    Best regards.

    Thread Starter chadtesting

    (@chadtesting)

    Hi CodePeople, thanks for helping.

    I understand exactly what you’re saying and I’m trying it and it still doesn’t work. I’ll attach screenshots.

    https://postimg.org/image/ddn4ugct1/

    https://postimg.org/image/v41kuvonr/

    https://postimg.org/image/ufsqbxpxz/

    In order…

    1.) DS Dropdown

    2.) DS Recordset

    3.) Output field (Calculated field)

    Now when I choose a choice from column_a in fieldname43, it should also return column_c in fieldname87

    I’m importing the same CSV in both fields.

    Best Regards,

    Chad

    Plugin Author codepeople

    (@codepeople)

    Hello,

    I’m sorry, but you have not understood how the “DS” fields work, your records in the recordset do not include the columns: column_a, column_b, etc. in your case the columns are: 0, 1, 2, 3

    Furthermore, the fieldname87 is a recordset field, you are not returning anything in this field, in reality you want to return the value in the fieldname88 that is the calculated field, so, the equation would be:

    (function(){
        var records = fieldname87;
    
        foreach(var i in records)
        {
            if(records[i][1] == fieldname43)
            {
                return records[i][3];
            }
        }
    }
    })()

    I’m sorry, but I can’t continue developing your project, ticket to ticket (I’ve replied to 68 of your tickets).

    If you need help implementing your particular project, you should hire a custom coding service.

    Best regards.

    Thread Starter chadtesting

    (@chadtesting)

    Hi CodePeople,

    Well on the bright side, it seems to be a quiet day on the forums!

    I am definitely interested in learning how the Recordset DS fields work within your plugin, so if there are examples I’m missing that will help me solve this problem myself, I’d be happy to research it. As it stands, I would have no way to know whether the plugin interprets csv columns as ‘column_a’ or [0]. I was just taking you at your word.

    This still isn’t resolved however. Is it possible that the foreach is syntactically problematic? When I run it through a delinter, it seems to have a problem with the following line:

    foreach(var i in records)

    I am executing the code exactly as described above.

    Best Regards,

    Chad.

    Plugin Author codepeople

    (@codepeople)

    Hello,

    My apologies, totally my fault, in javascript does not exists “foreach”, but I pass all the day implementing in different programming languages, and sometimes my brain betrays me, the correct code would be:

    (function(){
        var records = fieldname87;
    
        for(var i in records)
        {
            if(records[i][1] == fieldname43)
            {
                return records[i][3];
            }
        }
    }
    })()

    The CSV files can be defined with headlines as the first row, or not. If you have defined a headline in the CSV file, for example with the name of columns: column_a, column_b, column_c, the comparison would be: records[i]['column_b'] == fieldname43, but if the CSV file does not includes a headline row, the columns would be a numeric index starting in zero: 0, 1, 2, and the comparison would be: records[i][1] == fieldname43

    Best regards.

    Thread Starter chadtesting

    (@chadtesting)

    Hmm.. Are you sure there isn’t some extra logic to code the ‘on change’ value for the dropdown field? Does it read the change in values dynamically to generate the text?

    I’ve tried it a hundred different ways and the the thing won’t generate any output. I also removed a closed curly bracer from the original equation, as I think there was one too many.

    (function(){
        var records = fieldname90;
    /** fieldname90 is the ds recordset. **/
        for(var i in records)
        {
            if(records[i][0] == fieldname91)
    /** fieldname91 is the ds dropdown. Record 0 is the field to match. Record 3 is the text field to return. **/
            {
                return records[i][3];
       /** } **/     
        }
    }
    /** fieldname88 is the calculated field **/
    })()

    I’m pretty sure I am understanding you perfectly but there’s something small missing.

    Thread Starter chadtesting

    (@chadtesting)

    Sorry, but there is something missing still. I wonder if some sort of ‘on change’ logic needs to be added for the dropdown field? Is it supposed to evaluate it dynamically? I’ve removed the extra closed curly bracer in your equation as well.

    (function(){
        var records = fieldname90;
    /** fieldname90 is the ds recordset. **/
        for(var i in records)
        {
            if(records[i][0] == fieldname91)
    /** fieldname91 is the ds dropdown. Record 0 is the field to match. Record 3 is the field to return. Text is the value to return. **/
            {
                return records[i][3];
            
        }
    }
    /** fieldname88 is the calculated field **/
    })()
    Plugin Author codepeople

    (@codepeople)

    Hello,

    Please, include the link to the public web page where the form is, or I cannot check your formulas.

    Best regards.

    Thread Starter chadtesting

    (@chadtesting)

    Hi CodePeople,

    https://www.futureu.ca

    The code is on pg6. I can give you back end access if needed.

    Thank you

    Plugin Author codepeople

    (@codepeople)

    Hello,

    Yes please, don’t make check all tickets to search the URLs and accesses.

    Thanks

    Thread Starter chadtesting

    (@chadtesting)

    OK the form is ready. [CP_CALCULATED_FIELDS id=”7″] The fields start near the bottom at fieldname43.

    Use the following images for reference:
    https://postimg.org/image/hl0uzv71t/
    https://postimg.org/image/75j2izb8v/

    I’ve emailed you username/password access.

    Best Regards,

    Chad.

    Plugin Author codepeople

    (@codepeople)

    Hello,

    The URLs to the images files in the links you sent me are broken.

    Best regards.

    Thread Starter chadtesting

    (@chadtesting)

    These ones?
    https://postimg.org/image/hl0uzv71t/
    https://postimg.org/image/75j2izb8v/

    They are working fine from here.. It’s just a postimg URL

    Thread Starter chadtesting

    (@chadtesting)

    This is resolved. For all those who may be wondering what the missing piece is, in the DS recordset, all fields you are using need to be highlighted. See below

    https://postimg.org/image/bl7ynzodx/

    Thank you, CodePeople

Viewing 14 replies - 1 through 14 (of 14 total)
  • The topic ‘Looking up a field using a recordset’ is closed to new replies.