
Field Grouping Layout Element
This is a continuation of Peter's thread, which was apparently deleted with the purge of the spam posts. I am suggesting a new Layout Element that would use the HTML <fieldset> tag to group fields on the the Form page which appears to be rendered using HTML anyway. It could be implemented in a way similar to adding fields to a table. Here is a screen shot from the Mac app that shows what I'm talking about...
The groups are just Formula fields in this case and use the html() function. The "Style" option has the "Background color" set to RGB 238, 238, 238. Here is the formula if anyone wants to try it out...
html("
<form>
<fieldset>
<legend>Group 1:</legend>
Text1:
<input type=""text"" name=""Text1"" value=""Testing 1"">
<br>
Text2:
<input type=""text"" name=""Text2"" value=""Testing 2"">
</fieldset>
</form>
")
Text6 and Text7 are Ninox Text fields and the Groups are formula fields using the html() function.
-
I really don't know what to say as an observer and user of Ninox. There are many requests that seemingly would be easy to implement given the model of the app, but they are ignored. In one of the few webinars I tuned into Alex mentioned they started using React... does that mean a complete rewrite? Of course there is the relatively new focus on No Code Low Code, but this request would seem to fit in that paradigm.
At this point, if you use the
html()
function for anything other than displaying information it looks like you will need to create a parser to get the information out. Personally, I don't think that's any more difficult than using html if you are going that route, especially if you kept it very sparse. On that note, I wrote a data scraper using Ninox to create a forum database. I scraped the Technical Help section last night which took about 25 minutes per 1000 threads and most of that time was a result of the http calls. Scraping your own html in your database would be instantaneous. -
Sean, the following works and the "Get Value" button does not even need to be in the same formula field. Now I just need to know how to persist the values to Ninox fields.
html("
<form>
<fieldset>
<legend>Group 1:</legend>
Text1:
<input type='text' name='Text1' value='Testing 1' id='input1'>
Text2:
<input type='text' name='Text2' value='Testing 2' id='input2'>
</fieldset>
<button type='button' onclick='getInputValue();'>Get Value</button>
<script>
function getInputValue(){
var value1 = document.getElementById('input1').value;
var value2 = document.getElementById('input2').value;
alert(value1 + '\n' + value2);
}
</script>
</form>
")
-
At this point I am unable to make it work. This is what I put in a Forumula field...
html("
<fieldset>
<legend>Group 1:</legend>
Text1:
<input type='text' name='Text1' value='Testing 1' id='input1'>
<p id='Text1'></p>
Text2:
<input type='text' name='Text2' value='Testing 2' id='input2'>
<p id='Text2'></p>
</fieldset>
<button type='button' onclick='getInputValue();'>Get Value</button>
<script>
function getInputValue(){
var value1 = document.getElementById('input1').value;
var myObj1 = document.getElementById('input1');
myObj1.remove();
document.getElementById('Text1').innerHTML = value1;
var value2 = document.getElementById('input2').value;
var myObj2 = document.getElementById('input2');
myObj2.remove();
document.getElementById('Text2').innerHTML = value2;
}
</script>
")
The changes are made in the field with the HTML, but the
raw()
function does not return the updated HTML. What I expected from theraw()
function is the value between<p id='Text1'>
and</p>
. If that worked you could use theindex()
andsubstring()
functions to parse the values and assign those to Ninox fields. -
Sean, I have assumed that the API approach would not work because anything executed from within a formula field would be seen as being outside of Ninox. I would prefer not to have to use a outside service like Integromat. I have nothing against Integromat, I just think the additional cost and reduction in speed would not be a good fit for this situation.
-
Dean, I haven't had any coffee yet and I shouldn't have said I have zero experience with it. I experimented with the examples using code in a button and copied the result to a Text field...
let response := do as server
http("POST", "https://api.ninox.com/v1/teams/NDKpJAeL7bWtZBncq/databases/c43myvb6qcoh/tables/B/record", {
Authorization: "Bearer " + NK,
'Content-Type': "application/json"
}, {
A: "Stewart & Stevenson"
})
end;
if response.error then
alert(text(response.error))
else
'Returned Record' := text(response.result)
end
If we're following the same approach with a formula field, you would have to use something like
fetch()
in javascript instead ofhttp()
in Ninox. I just learned a little about it last night after a long day so I don't much detail to offer. I don't think something like Integromat is necessary to access their API. -
@Sean,
Rather then setting the 'Returned Record' to text... You can just set it to response.result. It is now a json object.. So you can then reference the fields like..
'Returned Record'.Name
parseJSON(jsonString);
This way.. if the third party changes their record structure .. but presumeably NOT the keys... I can keep going..
On several of my integrations.. I store only the key fields... then the entire json object as text... I can then pull it back out of the table row using
-
oops.... not sure how this got flipped around.... Here is what the post was SUPPOSED to look like..
@Sean,
Rather then setting the 'Returned Record' to text... You can just set it to response.result. It is now a json object.. So you can then reference the fields like..
'Returned Record'.Name
On several of my integrations.. I store only the key fields... then the entire json object as text... I can then pull it back out of the table row using
parseJSON(jsonString);
This way.. if the third party changes their record structure .. but presumeably NOT the keys... I can keep going..
-
@Mconneen, Thank you. I figured there was a better way and I'm afraid I have parsing on the brain right now. I really haven't spent any time with the REST API since this, https://ninox.com/en/forum/technical-help-5ab8fe445fe2b42b7dd39ee7/ninox-http-calls-syntax-5c83993071d2ba74f1399907. Dean's use case got me interested again.
In the thread above part of the discussion was about queries. I saw in the updated documentation that filtering is available. Have you tried it yet?
-
Thank you Sean and Mconneen. This is now working every time:
let response := do as server
http("POST", "https://api.ninox.com/v1/teams/" + yourTeamKey + "/databases/" + yourDatabaseKey + "/tables/A/record", {
Authorization: "Bearer " + yourAPIKey,
'Content-Type': "application/json"
}, {
A: "Stewart & Stevenson"
})
end;
if response.error then
alert(text(response.error))
else
let obj := response.result;
'Returned Record' := obj.fields.Name
end
-
Hi Robert,
Whe you use the http() function to access a URL, you can get the HTML from the page. Then you have to find the items you want to save. This is what I use to get a forum page title...
let htmlString := response;
let startString := "<h3 class=""mt-16 mb-24"">";
let endString := "</h3>";
let startStringLen := length(startString);
let substringStartPos := index(htmlString, startString) + startStringLen;
let substringEndPos := substringStartPos + index(substr(htmlString, substringStartPos), endString);
This is how I save it to the 'Thread Title' field...
'Thread Title' := replaceHTMLEntitiesAndTags(substring(htmlString, substringStartPos, substringEndPos))
-
Hi Sean, ok i know and understand your way for retrieve the data. But my problem is how can scrap data from a formula fields where i use html().
E.g. i have a html code, where it show a basic text field. i use formula field : html(my code for my html text field). Now if i insert : my name to the field i want scrap the value in a variable in the ninox.
i turn arrond this from many days(month), but i cant grap the value. Why? Because ninox evaluate my code whit her function html() then if i raw() my html its is always the base code html, and not with my value inside.
Any idea?
Best Regards