Concatination and overall use of JSedit

I am trying to learn to use the JSedit. I have went through some tutorials on this site and have tried many things but to no luck. I want to reach out to you guys and see if you can point me not only in the right direction but perhaps some material to further my understanding of your solution. I want to better understand what is going on with the code. That being said what I want this to do: The user wil pull down an item from the Equipment dropdown (Radio or Flashlight) and then they will type in the equpment ID number (could be a single number or could be something like “basement-3”. This will automatically be concatinated with the equipment number and in the unique ID box and display immediately “Flashlight - Basement-3” and then the user can hit the + and add a new layer to the record adding something like “Radio - 5” into that next row of the subtable. 

 

Please give me a hand on putting this together.

 

Tyler

 

Hello Tyler,

Regarding the JS edit, I assume that you read the following document?
 Kintone Developer Program - JSEdit
 https://developer.kintone.io/hc/en-us/articles/115003211388-JSEdit
Precisely what part are you having difficulty? Is it a kintone specific stuff?

And about the concatenating stuff that you are trying to do, you could do this by the native feature.
Try to do the following:

  1. Place three fields: the dropdown field, the equipment ID number (text) field, and another text field
  2. In the 2nd text field settings, place a check on “Calculate automatically.”
  3. After you place the check, you should see a blank space right beneath it, enter the following:
    “Field Code for the Dropdown Field” & “(Blank Space)” & “Field Code for the Equipment ID Number field.”

Kintone Help - & Operator: Concatenating Strings
https://get.kintone.help/k/en/user/app_settings/form/autocalc/text_autocalc.html

By doing the above, it should concatenate the texts from the selected fields even after you make them as a table.

Yuzo,

 

Thank you for writing back. My question is more for use of knowing how to do this in JSedit. I know this is a native feature in kintone but I want to do it this way so that I can learn how to manipulate items inside JSedit. The function of this program is not exactly my end game, it is just a teaching tool.

 

That being said, I do know what my specific issue is. I would have believed my code, as written, would work. When I save the code and return to the application the items in the subtable to do not concatenate. That means something is wrong in my program but I have no idea what that is. I’m not sure if it’s a display command issue, referencing of the table rows, how I am gathering the VAR or recording the data. It’s all foreign to me but it will definately teach me a lot to learn how to do concatenation in this form.

Hello Tyler!

In that case, from what I see, I think these need to be corrected:
*I assume the field codes are correct

  1. table[i].Dropdown_0.value > tableRecords[i].value[‘Dropdown_0’].value
  2. table[i].Equipment_ID.value > tableRecords[i].value[‘Equipment_ID’].value
  3. record.equimentTable.Unique_ID.value > tableRecords[i].value[‘Unique_ID’].value

So I did these changes. I feel like there may be something wrong with the other items of the code, at the kintone.events.on( portion. The reason i say that is when I save the JSedit and try to create a new record I can type everything in properly but when I press SAVE to submit the item nothing happens. The record doesn’t save and it just sits there. So i’m thinking something is wrong with one piece of the code, that I’m not sure how to diagnose. Also brings up another good questions, do you guys have a log file that I can look at to see what portion of the code is failing. Like an error log?

I’m not sure about the log file, but you could always debug it to see which portion of the script is experiencing the error.

Kintone Developer Program - Debugging tips for Kintone JS
https://developer.kintone.io/hc/en-us/articles/115003211768-Debugging-tips-for-Kintone-JS

 

Ok. I will investigate further now.

 

Besides the for loop, do you have any comments on the other parts of my code that I could try changing to get to work, or does it look proper?

 

 

Hello Tyler,

In order to use the event object and to renew the value, you must return the event object.  
However, the record you are using currently, the detailed screen display event “app.record.detail.show”, the record value cannot be renewed on event object.

If you wish to renew at this point, it would be best to use REST API(PUT) and process it.

In that case, it would be a bit difficult.  
So this time, change the events to an event that is saved before the record, such as, “app.record.create,submit” or “app.record.edit.submit” and add “return event” after the 10th row within the current code.