When defining a new array for a local variable, I would like to separate the values to be stored when the existing array is NULL and when it is not. Is it possible? ローカル変数に新しい配列を定義するとき、既存の配列がNULLのときとそれ以外で格納する値を分けたいです。実現可能でしょうか?

I am always indebted. I have a question for all you kind people.
Store the array obtained from the record type in the first local variable.
Stores a new array that adds part of the value of the first local variable to the second local variable.
This second local variable will be used to display the graph.

The first local variable stores data corresponding to the rule input value, if any. However, in rare cases, the value entered may not exist for the record type being queried. At this time, the value of the first local variable will be [].

Here comes the problem. When defining the value of the second local variable, there is no problem if the first local variable has a value other than []. However, if it is [], the addition process will not be possible and an error will occur. I would like to solve this problem, but are there any appropriate functions or ideas?

When defining the second local function, if I included an IF function or a NULL check, the variable definition did not work. If anyone knows, please let me know. Thank you.

いつもお世話になっています。親切な皆様に質問があります。
1つめのローカル変数に、レコードタイプから取得した配列を格納します。
2つめのローカル変数に、1つ目のローカル変数の値の一部を加算した新しい配列を格納します。
この2つめのローカル変数を、グラフの表示に使用します。

1つめのローカル変数には、ルール入力された値がある場合はそれに応じたデータを格納します。しかしまれに、入力された値がクエリ対象のレコードタイプに存在しないケースがあります。このとき、1つめのローカル変数の値は [] になります。

ここで問題が発生します。2つ目のローカル変数の値を定義するとき、1つめのローカル変数が [] 以外の値であれば問題ありません。しかし[]だった場合は、加算の処理ができずにエラーが発生します。この問題を解決したいのですが、適切な関数や工夫はありますでしょうか?

2つめのローカル関数を定義する際にIF関数やNULLチェックを挟むと変数定義がうまくいきませんでした。もしご存じの方がいれば教えて頂きたいです。よろしくお願いいたします。

  Discussion posts and replies are publicly visible

Parents
  • Dear everyone.
    Thank you very much for your comments and responses.
    This issue has been resolved.

    Initially, I wanted to close it inside the interface, but that didn't work. This is because if you used if() or isNullOrEmpty() at the same time as declaring a variable, the behavior did not work as expected.
    However, this has become possible by leaving variable declaration to the interface and separating the subsequent steps (NULL checking and output) into new expression rules.

    if(
      a!isNullOrEmpty(ri!graphValue),
      ri!graphValue,
      {
        ri!graphValue[1],
        ri!graphValue[1]+ri!graphValue[2],
        ri!graphValue[1]+ri!graphValue[2]+ri!graphValue[3],
        ri!graphValue[1]+ri!graphValue[2]+ri!graphValue[3]+ri!graphValue[4],
        ri!graphValue[1]+ri!graphValue[2]+ri!graphValue[3]+ri!graphValue[4]+ri!graphValue[5],
        ri!graphValue[1]+ri!graphValue[2]+ri!graphValue[3]+ri!graphValue[4]+ri!graphValue[5]+ri!graphValue[6],
        ri!graphValue[1]+ri!graphValue[2]+ri!graphValue[3]+ri!graphValue[4]+ri!graphValue[5]+ri!graphValue[6]+ri!graphValue[7],
        ri!graphValue[1]+ri!graphValue[2]+ri!graphValue[3]+ri!graphValue[4]+ri!graphValue[5]+ri!graphValue[6]+ri!graphValue[7]+ri!graphValue[8],
        ri!graphValue[1]+ri!graphValue[2]+ri!graphValue[3]+ri!graphValue[4]+ri!graphValue[5]+ri!graphValue[6]+ri!graphValue[7]+ri!graphValue[8]+ri!graphValue[9],
        ri!graphValue[1]+ri!graphValue[2]+ri!graphValue[3]+ri!graphValue[4]+ri!graphValue[5]+ri!graphValue[6]+ri!graphValue[7]+ri!graphValue[8]+ri!graphValue[9]+ri!graphValue[10],
        ri!graphValue[1]+ri!graphValue[2]+ri!graphValue[3]+ri!graphValue[4]+ri!graphValue[5]+ri!graphValue[6]+ri!graphValue[7]+ri!graphValue[8]+ri!graphValue[9]+ri!graphValue[10]+ri!graphValue[11],
        ri!graphValue[1]+ri!graphValue[2]+ri!graphValue[3]+ri!graphValue[4]+ri!graphValue[5]+ri!graphValue[6]+ri!graphValue[7]+ri!graphValue[8]+ri!graphValue[9]+ri!graphValue[10]+ri!graphValue[11]+ri!graphValue[12]
      }
    ),

    Thank you for your many tips and cooperation. thank you!

    親愛なる皆様。
    沢山のお声かけ、ご回答をありがとうございました。
    こちらの問題は解決いたしました。

    当初、はインターフェース内でクローズさせたかったのですが、それは叶いませんでした。変数の宣言と同時にif()やisNullOrEmpty()を使用すると想定通りの挙動にならなかったためです。
    しかし、変数宣言はインターフェースに任せて、その後工程(NULLチェックと出しわけ)を新しく式ルールに分離することで実現が可能になりました。

    if(
      a!isNullOrEmpty(ri!graphValue),
      ri!graphValue,
      {
        ri!graphValue[1],
        ri!graphValue[1]+ri!graphValue[2],
        ri!graphValue[1]+ri!graphValue[2]+ri!graphValue[3],
        ri!graphValue[1]+ri!graphValue[2]+ri!graphValue[3]+ri!graphValue[4],
        ri!graphValue[1]+ri!graphValue[2]+ri!graphValue[3]+ri!graphValue[4]+ri!graphValue[5],
        ri!graphValue[1]+ri!graphValue[2]+ri!graphValue[3]+ri!graphValue[4]+ri!graphValue[5]+ri!graphValue[6],
        ri!graphValue[1]+ri!graphValue[2]+ri!graphValue[3]+ri!graphValue[4]+ri!graphValue[5]+ri!graphValue[6]+ri!graphValue[7],
        ri!graphValue[1]+ri!graphValue[2]+ri!graphValue[3]+ri!graphValue[4]+ri!graphValue[5]+ri!graphValue[6]+ri!graphValue[7]+ri!graphValue[8],
        ri!graphValue[1]+ri!graphValue[2]+ri!graphValue[3]+ri!graphValue[4]+ri!graphValue[5]+ri!graphValue[6]+ri!graphValue[7]+ri!graphValue[8]+ri!graphValue[9],
        ri!graphValue[1]+ri!graphValue[2]+ri!graphValue[3]+ri!graphValue[4]+ri!graphValue[5]+ri!graphValue[6]+ri!graphValue[7]+ri!graphValue[8]+ri!graphValue[9]+ri!graphValue[10],
        ri!graphValue[1]+ri!graphValue[2]+ri!graphValue[3]+ri!graphValue[4]+ri!graphValue[5]+ri!graphValue[6]+ri!graphValue[7]+ri!graphValue[8]+ri!graphValue[9]+ri!graphValue[10]+ri!graphValue[11],
        ri!graphValue[1]+ri!graphValue[2]+ri!graphValue[3]+ri!graphValue[4]+ri!graphValue[5]+ri!graphValue[6]+ri!graphValue[7]+ri!graphValue[8]+ri!graphValue[9]+ri!graphValue[10]+ri!graphValue[11]+ri!graphValue[12]
      }
    ),

    沢山のヒントとご協力に感謝いたします。ありがとう!

Reply
  • Dear everyone.
    Thank you very much for your comments and responses.
    This issue has been resolved.

    Initially, I wanted to close it inside the interface, but that didn't work. This is because if you used if() or isNullOrEmpty() at the same time as declaring a variable, the behavior did not work as expected.
    However, this has become possible by leaving variable declaration to the interface and separating the subsequent steps (NULL checking and output) into new expression rules.

    if(
      a!isNullOrEmpty(ri!graphValue),
      ri!graphValue,
      {
        ri!graphValue[1],
        ri!graphValue[1]+ri!graphValue[2],
        ri!graphValue[1]+ri!graphValue[2]+ri!graphValue[3],
        ri!graphValue[1]+ri!graphValue[2]+ri!graphValue[3]+ri!graphValue[4],
        ri!graphValue[1]+ri!graphValue[2]+ri!graphValue[3]+ri!graphValue[4]+ri!graphValue[5],
        ri!graphValue[1]+ri!graphValue[2]+ri!graphValue[3]+ri!graphValue[4]+ri!graphValue[5]+ri!graphValue[6],
        ri!graphValue[1]+ri!graphValue[2]+ri!graphValue[3]+ri!graphValue[4]+ri!graphValue[5]+ri!graphValue[6]+ri!graphValue[7],
        ri!graphValue[1]+ri!graphValue[2]+ri!graphValue[3]+ri!graphValue[4]+ri!graphValue[5]+ri!graphValue[6]+ri!graphValue[7]+ri!graphValue[8],
        ri!graphValue[1]+ri!graphValue[2]+ri!graphValue[3]+ri!graphValue[4]+ri!graphValue[5]+ri!graphValue[6]+ri!graphValue[7]+ri!graphValue[8]+ri!graphValue[9],
        ri!graphValue[1]+ri!graphValue[2]+ri!graphValue[3]+ri!graphValue[4]+ri!graphValue[5]+ri!graphValue[6]+ri!graphValue[7]+ri!graphValue[8]+ri!graphValue[9]+ri!graphValue[10],
        ri!graphValue[1]+ri!graphValue[2]+ri!graphValue[3]+ri!graphValue[4]+ri!graphValue[5]+ri!graphValue[6]+ri!graphValue[7]+ri!graphValue[8]+ri!graphValue[9]+ri!graphValue[10]+ri!graphValue[11],
        ri!graphValue[1]+ri!graphValue[2]+ri!graphValue[3]+ri!graphValue[4]+ri!graphValue[5]+ri!graphValue[6]+ri!graphValue[7]+ri!graphValue[8]+ri!graphValue[9]+ri!graphValue[10]+ri!graphValue[11]+ri!graphValue[12]
      }
    ),

    Thank you for your many tips and cooperation. thank you!

    親愛なる皆様。
    沢山のお声かけ、ご回答をありがとうございました。
    こちらの問題は解決いたしました。

    当初、はインターフェース内でクローズさせたかったのですが、それは叶いませんでした。変数の宣言と同時にif()やisNullOrEmpty()を使用すると想定通りの挙動にならなかったためです。
    しかし、変数宣言はインターフェースに任せて、その後工程(NULLチェックと出しわけ)を新しく式ルールに分離することで実現が可能になりました。

    if(
      a!isNullOrEmpty(ri!graphValue),
      ri!graphValue,
      {
        ri!graphValue[1],
        ri!graphValue[1]+ri!graphValue[2],
        ri!graphValue[1]+ri!graphValue[2]+ri!graphValue[3],
        ri!graphValue[1]+ri!graphValue[2]+ri!graphValue[3]+ri!graphValue[4],
        ri!graphValue[1]+ri!graphValue[2]+ri!graphValue[3]+ri!graphValue[4]+ri!graphValue[5],
        ri!graphValue[1]+ri!graphValue[2]+ri!graphValue[3]+ri!graphValue[4]+ri!graphValue[5]+ri!graphValue[6],
        ri!graphValue[1]+ri!graphValue[2]+ri!graphValue[3]+ri!graphValue[4]+ri!graphValue[5]+ri!graphValue[6]+ri!graphValue[7],
        ri!graphValue[1]+ri!graphValue[2]+ri!graphValue[3]+ri!graphValue[4]+ri!graphValue[5]+ri!graphValue[6]+ri!graphValue[7]+ri!graphValue[8],
        ri!graphValue[1]+ri!graphValue[2]+ri!graphValue[3]+ri!graphValue[4]+ri!graphValue[5]+ri!graphValue[6]+ri!graphValue[7]+ri!graphValue[8]+ri!graphValue[9],
        ri!graphValue[1]+ri!graphValue[2]+ri!graphValue[3]+ri!graphValue[4]+ri!graphValue[5]+ri!graphValue[6]+ri!graphValue[7]+ri!graphValue[8]+ri!graphValue[9]+ri!graphValue[10],
        ri!graphValue[1]+ri!graphValue[2]+ri!graphValue[3]+ri!graphValue[4]+ri!graphValue[5]+ri!graphValue[6]+ri!graphValue[7]+ri!graphValue[8]+ri!graphValue[9]+ri!graphValue[10]+ri!graphValue[11],
        ri!graphValue[1]+ri!graphValue[2]+ri!graphValue[3]+ri!graphValue[4]+ri!graphValue[5]+ri!graphValue[6]+ri!graphValue[7]+ri!graphValue[8]+ri!graphValue[9]+ri!graphValue[10]+ri!graphValue[11]+ri!graphValue[12]
      }
    ),

    沢山のヒントとご協力に感謝いたします。ありがとう!

Children
  • 0
    Certified Senior Developer
    in reply to misakib0705

     No Problem, Happy to help Slight smile

  • 0
    Certified Lead Developer
    in reply to misakib0705
    if you used if() or isNullOrEmpty() at the same time as declaring a variable, the behavior did not work as expected

    This isn't really true, though - you just need to use the correct syntax and variable declaration structure.  Some of the things you were trying originally weren't really structured correctly at first, and you've side-stepped the whole issue in your working implementation here (but that doesn't mean it wouldn't have worked with the correct structure).  I can't 100% discern what you were wanting to accomplish, otherwise I would offer you a working example of how to have done it in the way most closely matching what you were originally trying...

  • 0
    Certified Lead Developer
    in reply to Mike Schmitt

    Additionally, if you're trying to add the (numeric) elements of an array, a vastly shorter way of writing them all out long-hand would be to use the function sum().  In case that helps you cut down on your final code length or implementation burden.

  • Thank you very much, your kindness always helps me, thank you very much.

  • thank you. What I originally wanted to do was to return NULL if the value was NULL, and add the elements of the array if it was NULL.
    (I asked you questions before I fully understood the logic myself, so it may be difficult to understand. I apologize for the inconvenience...)

    If the value is not NULL, and the value {1,2,3} is passed, the process returns {1,3,6}.
    The breakdown is the formula {1, 1+2, 1+2+3}.
    It's a bit redundant, but I prioritized movement and ended up with this shape.

    This was to create data to be used for graph display, and it was necessary to add 12 months worth of data. The logic is to return NULL if there is no value, and if there is a value, return an array that has been added 12 times.
    However, this way of writing will cause a runtime error. If the passed array has less than 12 elements, addition cannot be performed and an error will occur.

    We solved this problem by specifying the number of elements and passing it to the path that matches it. If there are only 11 elements, add 0 instead of the 12th element.
    There are still some issues left, but we hope to resolve them little by little. I'll try SUM() as well. Thank you very much for teaching me so carefully.

    ありがとうございます。私が当初やりたかったことは、値がNULLだった場合はNULLを返却し、NULLではい場合は配列の要素を加算していく処理でした。
    (私自身がロジックを理解しきれていないタイミングで皆様に質問をさせていただいていたため、伝わりにくい可能性があります。ご迷惑をおかけします。。。)

    値がNULL出ない場合、{1,2,3}という値が渡されれば、{1,3,6}が返却されるような処理です。
    内訳は{1, 1+2, 1+2+3}という計算式になります。
    冗長なのですが、動くことを最優先して一旦この形になりました。

    これはグラフ表示に使うデータを作成するもので、12か月分加算処理する必要がありました。値がない場合はNULLを返却し、値がある場合は12回加算処理した配列を返却する、というロジックです。
    しかしこの書き方では実行時エラーが発生します。渡された配列の要素が12未満の場合に加算処理ができずエラーになることです。

    この点については要素数を特定してそれに見合うパスへ通すようにして解決しました。11要素しかない場合、12個目の要素の代わりに0を加算します。
    まだいくつかの問題は残っていますが、少しずつ解決していきたいと考えています。SUM()も試してみますね。丁寧に教えてくれて本当にありがとうございます。