Jump to content

DefinitelyNot31337

Caspio Ninja
  • Content Count

    80
  • Joined

  • Last visited

  • Days Won

    4

DefinitelyNot31337 last won the day on January 6

DefinitelyNot31337 had the most liked content!

2 Followers

About DefinitelyNot31337

  • Rank
    Advanced Member

Recent Profile Visitors

208 profile views
  1. DefinitelyNot31337

    Resize TextBox

    Hi, Just adding a bit of modification to @kristina's answer. With the advent of AJAX-enabled DataPages (Caspio r14), this CSS rule might not work if that feature is enabled due to the appended id text on the elements. In that case, you may use the updated snippet below then modify it after paste: <style> input[id*="InlineAddFIELDNAME"] {width: 20px !important;} input[id*="InlineAddFIELDNAME"] {width: 30px !important;} </style> An easier but more sophisticated solution is to just paste this code in the FOOTER of your Results Page, then modify the field_name and target_size. <script> var field_name = 'created_on'; // <--Put your field name inside the quotes var target_size = '8'; // <--Put your target size inside the quotes /*Modifications are NOT necessary from this point below*/ var date_field = document.querySelector(`[action*="[@cbAppKey]"] [id*=InlineAdd${field_name}] `); date_field.size = target_size; </script> Cheers, DN31337
  2. DefinitelyNot31337

    Login script that checks a box in table during log in

    In addition to my previous post, > It works just by importing. > You will need to Bulk Deploy all the DataPages before you'll be able to use it. > The isLoggedIn field will not be unchecked unless the user goes to the Logout DataPage. In that case, just create a Task that will cleanse your Users table Regards, DN31337
  3. DefinitelyNot31337

    Login script that checks a box in table during log in

    Hi, Just to elaborate @AtayBalunbalunan's solution, you may try to implement this solution. 0.) Add an 'isLoggedIn' field (DataType: Yes/No) to your Users Table. 1.) For your Login, Create a Single-Record Update (SRU) DataPage (Login DataPage) and set Restrict Access to your Authentication 1.1.) Set your isLoggedIn field to 'Hidden' and check OnLoad, receive "Yes" 1.2.) Create a Virtual Field and check OnExit in the Advanced Tab. 1.3.) Create a Footer, disable the HTML Editor from the Advanced Tab, paste>modify the code snippet <script> var vf = document.querySelector(`[action*='[@cbAppKey]'] [id*=cbParamVirtual1]`); if ('[@field:role]' == 'admin') { vf.value = "https://www.google.com"; } else if ('[@field:role]' == 'user') { vf.value = "https://www.youtube.com"; } else { vf.value = "https://www.facebook.com" } vf.form.submit(); </script> 1.4.) Set your Destination Options to 'Go to a new page', and set the Page URL to go to [@Virtual1]. 2.) Set your Authentication > Timeout and redirection > Designated entry Page to 'Go to a DataPage' and set it to your Login DataPage 3.) For your Logout, duplicate>rename your Login DataPage (Let's call it Logout DataPage for this example) 3.1.) Set your isLoggedIn field to 'Hidden' and un-check OnLoad, receive "Yes" 3.2) Replace the entire footer code with the snippet below, and hit Finish: <script> var vf = document.querySelector(`[action*="[@cbAppKey]"] [id*=cbParamVirtual1]`); vf.value += '/folderlogout'; vf.form.submit(); </script> For all your logout Links, just point your users to Logout DataPage to uncheck the isLoggedIn field from your users table. Also attaching the app that I made with this implementation though you might need to modify the links in ILI Login DataPage > Footer for it to work. Is_Logged_In_1_0_2019-Jan-08_2340.zip The usernames are: dn31337, user1, and user2. Hope this helps. Cheers, DN31337
  4. Hello once again TroubleShooter, You ask such challenging/brain-teasing problems. Luckily I had my power-ups tonight and I am up for this challenge. I am able to find a somewhat viable solution. I hope the code speaks for itself too. *kidding*. So paste>modify these code snippets in their respective places. Make sure that HTML Editor is disabled from the advanced tab. Note: This only works for Level1 Grouping and it works best if you put the title (i.e. details) field in the end. I need more time to customize this solution further. Header <script> var init = []; var temp = (new Date).toLocaleString() + "1AmD3f1n1t3lyN0t31337!"; function comparaPush(groupByField, titleField) { if (temp != groupByField) init.push(titleField); var temp = groupByField; } </script> HTML Block (*modification needed) [Regarding placement, there's only one room for error. 1/#OfFields] <script> var groupByField = "[@field:category]"; //This is your Grouping Field var titleField = "[@field:details]"; //And this is your Title Field. The one that you'd be putting on your collapsible row comparaPush(groupByField, titleField); </script> Footer <script> var groups = document.querySelectorAll(`[data-cb-name="group1"]`); groups.forEach(rowalize); function rowalize(elem, idx) { elem = elem.firstChild; elem.colSpan-=1; elem.insertAdjacentHTML('afterend', `<td class="cbResultSetGroup1Label cbResultSetGroup1LabelCellNumberDate">${init[idx]}</td>`) } </script> Hope this works for you. Happy Hacking! Cheers, DN31337
  5. Hey Carlson, Your question is a bit off-topic to this thread, but the answer to your question is yes, you may. If you wanted to "hide" the Delete button in general (NOT record-specific), you may paste>modify this code on your Footer with HTML Editor disabled in the Advanced tab: <script> var condition = ("[@authfield:role]" != "admin"); //Your condition /*Edits are not necessary from this point onward */ var deleteButtons = document.querySelectorAll('[data-cb-name="InlineDelete"]'); if(condition) { deleteButtons.forEach(function (elem) { elem.style.display = "none"; }); } </script> ==== A per-record implementation is a bit more complex, paste the following code snippets in their respective places with HTML Editor disabled. The only modification needed is the "condition" Header <script> var toHide = []; function hideDelete(idx, cond) { if (cond) toHide.push((idx-1)*2); } </script> HTML Block <script> var condition = ("[@field:created_by]" == "[@authfield:userid]"); hideDelete([@cbRecordIndex], condition); </script> Footer <script> var deleteButtons = document.querySelectorAll('[data-cb-name="InlineDelete"]'); toHide.forEach(function(elem) { deleteButtons[elem].style.display = "none"; deleteButtons[elem+1].style.display = "none"; }) </script> I hope this helps. If you have questions, I'd suggest to start another forum thread then mention me in there to keep this thread clean. Happy new year! Cheers, DN31337
  6. DefinitelyNot31337

    Convert to Capital Letters

    @JolliBeng, thanks for sharing that thread. I added an answer to that post, too. @Role21 you may want to check this out. I believe it's a more Caspio standard-feature way of implementing this. Hope this helps, DN31337
  7. DefinitelyNot31337

    Capitalizing All Letters

    Hi, On a Submission Form DataPage, you may also make use of a Calculated Value element. The idea is to create a virtual field to hold the value you wanted to convert to all-caps. Then for the actual field, the syntax would be something like: UPPER('[@cbParamVirtual1]') Then, you can just hide the virtual field in a <div style="display: none"> </div> block. Here's the how-to article (Scroll over to: Using HTML Blocks to hide fields). Hope this helps. Regards, DN31337
  8. DefinitelyNot31337

    Login Redirect for Report DataPages?

    Hey @kpcollier, If this is the case, just disable RLS. Then in your Reports DataPage, set the Ordered_By field to receive a default value from an Authentication Field. == Another approach and slightly unrelated. You may also try this neat trick. Just add a calculated field, CASE WHEN [@field:userId] = '[@authfield:userId]' THEN 1 ELSE 0 END Sort your results Then hide the Calculated Field column: https://howto.caspio.com/tech-tips-and-articles/common-customizations/how-to-hide-fields-in-datapages/ (via HTML Blocks) This way, the user's records always comes first, unless you filter it out. Hope this information helps. Happy Holidays, Cheers ! -DN31337
  9. DefinitelyNot31337

    Excel formulas easily used in Caspio?

    Hi @roattw, I replied on your other post. It seemed to work on my account when I tried to replicate it. You might have missed a few opening/closing parenthesis and/or misplaced them. Formulas can get really confusing especially when it's already long. Cheers, DN31337
  10. Were you trying the syntax below? It worked for me. You'd need to encapsulate the whole equation in an outer parenthesis before using it as an argument. ROUND( ( (4*[@field:Burn_Amnt]*[@field:Weight]) + (1500*[@field:BSA]) ), 0) Next, , were you trying to implement it on a Table or on a DataPage? If it's on a DataPage and the syntax didn't work for you, you can simply change the localization to NOT show the decimal. But it probably get the FLOOR of the result instead of round. Hope this helps. Regards, DN31337
  11. DefinitelyNot31337

    Delete box dialog doesn't fit on small screens

    Hi @TroubleShooter, Try pasting this snippet in the Header of your DataPage. These are media queries that set the width of the Dialog Box on shorter devices. <meta content="width=device-width, initial-scale=1" name="viewport" /> <style> #Alert { width: 500px; } @media screen and (max-width: 500px) { #Alert { width: 315px !important; } } </style> Tested this on PC but not on actual mobile device. Hope this works for you. Cheers, DN31337
  12. DefinitelyNot31337

    Formula

    Hello, We can also use the CONVERT function which functions exactly the same but with different syntax. In this case: '2018' + CONVERT(VARCHAR, [@field:School_ID]) + CONVERT(VARCHAR, [@field:Section_ID]) More information about function reference and Calculated Fields in these links: https://howto.caspio.com/function-reference/ https://howto.caspio.com/datapages/reports/advanced-reporting/calculations-in-forms-and-reports/ Regards, DN31337
  13. DefinitelyNot31337

    Javascript to display Select count of table column

    Hi techguy, Vitalikssssss solution is great but I'd like to present a different approach. 1.) You can add an Other_Contacts_Count field to your Users table; then 2.) Define a Trigger on your Ninja_Contacts table that says: OnInsert > Update Users SET Other_Contacts_Count = COUNT ninja_contacts.id WHERE ninja_contacts.Contact_Type = "Other" INNER JOIN #inserted ON users.id = ninja_contacts.User_ID Notes: (You will need to setup the JOIN first before you can select the fields.) The Trigger actually fires before the record is inserted so you will need to revise your syntax a bit. Refer to the related image attached. Ninja_Contacts = Child Users = Parent Ninja.Other_Contacts_Count = count_ready Contact_Type = Status == After then, you can access the contacts_count as an Authentication Field. I hope this makes sense and I hope I explained it well. I also attached the DataPage where I implemented this workflow. Cheers, DN31337 Tables_2018-Dec-18_0841.zip
  14. DefinitelyNot31337

    combine 2 tables for one submission form

    Hi Medron, You may try implementing a multi-step submission form (as documented here: https://howto.caspio.com/tech-tips-and-articles/common-customizations/how-to-create-a-multi-page-form/). You may also try creating another table to hold all the fields from your 2 tables, use the new table as the DataSource of your submission form(s), then create a Trigger to insert/edit data to your original tables. Documentation about triggers here => https://howto.caspio.com/tables-and-views/triggered-actions/ Hope this helps. -DN31337
  15. Another approach is to use JavaScript. It's similar to the previous post but we're going to use JavaScript in this one. By this approach: 1.) Same as previous post, first is to enclose your field/group of fields in a <div> tag, or <table> tag in HTML Blocks. (You will only need two HTML Blocks at most. If you want to hide an HTML Block, just enclose it in a <div> tag ). 2.) Instead of a class, put an ID attribute for each blocks we want to hide (the condition will be defined later in the JavaScript). Sample usage would be <div id="block1"> OR <div class="block1"> 3.) Once you have setup the class on the HTML Blocks, it's time to do JavaScript. Add a Footer, disable the HTML Editor from the Advanced tab, and paste the code below. (duplicate a whole block and edit the values as needed) <script> /* Block BEGIN */ var elemId = "block1"; var fieldName = "[@field:type]"; var fieldEqualTo = "typeA"; //Edits are unnecessary from this point to END var elem = document.querySelector(`[action*="[@cbAppKey]"] #${elemId}`); if (fieldName == fieldEqualTo) { elem.style.display = "none"; } /* Block END */ </script> 
×