0

Script Error on line 15

#{ Get the selected categories from the Choice (dynamic) field 'Categories' in the Control HH table }#;
let selectedCategories := Categories;
#{ Start an empty list to store the associated Rates to Categoty }#;
let associatedRates := [];
#{ Iterate over each selected category }#;
for y in selectedCategories do
    #{ Search the Categories table for the Rate associated with the category }#;
    let cat := first(select Categories where Category = y);
    #{ If the category exists, add the Rate to the list }#;
    if cat then
        associatedRates := associatedRates + cat.Rate
    end
end;
#{ Store the associated Rates in the Rate Category field of the Control table }#;
'Rate Categ' := join(associatedRates, ", ");

 

I don't know if there is logic in this script

4 replies

null
    • Fred
    • 2 mths ago
    • Reported - view

    Just to verify:

    1) Categories is a dynamic multi choice field. Your comment says it is a dynamic choice field.

    2) is the dynamic field pointing to the Categories table?

    If #2 is true from above then I don't know why you are looking again in the Categories table for the record?

    let cat := first(select Categories where Category = y);
    

    Since you are creating the dynamic field from the Categories table then the record exists.

    You can use the record() command to get the specific record you have selected.

    let cat := record(Categories,y)
    

    What are you trying to do with:

    associatedRates := associatedRates + cat.Rate
    
      • Rafael Sanchis
      • Rafael_Sanchis
      • 2 mths ago
      • Reported - view

       

      Hi Fred Categories is a Choice (dynamic) and yes is pointing to Catgories table.

      When use 

      let cat := record(Categories,y)
      

      Expression does not return a number

      I have tried to do this in several ways and have not been able to do it.

    • szormpas
    • 2 mths ago
    • Reported - view

    Hi  , I not sure what exactly you try to accomplish but can you try the following lines?

    let selectedCategories := numbers(Categories);
    let associatedRates := [0][false];
    associatedRates := array(associatedRates, cat.Rate);
    • Fred
    • 2 mths ago
    • Reported - view
     said:
    Categories is a Choice (dynamic) and yes is pointing to Catgories table.

    Ok, so then you don't need for loop as there is only 1 selection. reminded us to use the number() command so you get the record Id of the selection.

    let t := this;
    let cat := record(Categories,number(t.Categories))
    cat.Rate
    

    I don't know why you need an array.

Content aside

  • Status Answered
  • 2 mths agoLast active
  • 4Replies
  • 36Views
  • 3 Following