Jump to content

DesiLogi

Caspio Rockstar
  • Posts

    290
  • Joined

  • Last visited

  • Days Won

    22

Everything posted by DesiLogi

  1. Yeah, I know re the API and that wouldn't work. What would work is if you could call a function from a table's trigger--that would open up all kinds of possibilities. I was hoping someone had figured out a workaround.
  2. Hi, Part of my app is a chat/messaging module that enables users in the same account (it's a SaaS app where each customer might have multiple authenticated users in the same account) to 'chat' or message each other. Everything is good on it except I need to figure out how to show a popup notification to the user who a message is directed to, instantaneously, so they know they have one. I don't mean using the email or text message triggers (already have that enabled) but showing a small 'you have a new message' message in the lower right of the web page the app is hosted on. I've used sliding panels, fancybox, and straight popups in other areas so I imagine I can configure one of those methods to show the notification and new message content. The problem I'm having is, how do you trigger a function to open a notification popup/panel in another user's account, on a different computer entirely? So when User1 submits a new message directed to User2, User2 will get an instant notification in their own browser? I imagine it's some sort of listener setup but don't really know how it would work. If anyone has any suggestions that'd be great!
  3. I found the right answer to select the field to be Bulk Edited, as well as put a value in the field. You have to reference the check box for that field. Here's the full code in case anyone needs it: <SCRIPT LANGUAGE="JavaScript"> /* Declaration and initialization */ Stamp = new Date(); var v_TimeStamp; Hours = Stamp.getHours() Mins = Stamp.getMinutes(); /* Attach a prefix with digit '0' if the minutes is less than 10. */ if (Mins < 10) { Mins = "0" + Mins; } /* Construct the value of the v_TimeStamp variable in the format m/d/yyyy hh:mm */ v_TimeStamp=('' + (Stamp.getMonth() + 1) +"/"+Stamp.getDate() + "/"+Stamp.getFullYear() + ' ' + Hours + ":" + Mins); /* Field name - Date_Charge is referred with a prefix - EditRecord */ document.getElementById("BulkEditComments_Actual_Read_Date").value = v_TimeStamp; var checkboxName = "Enable"+ "BulkEditComments_Actual_Read_Date" + "Ckb"; document.getElementsByName(checkboxName )[0].checked=true; </SCRIPT>
  4. Hi, I'm trying to use js to get the user's system date/time on their local computer, in the Bulk Edit section of a tabular datapage. I've used this code in various other datapage types but cannot get it to work in the Bulk Edit footer. In the footer of Bulk Edit, the field is Comments_Actual_Read_Date but it's not capturing the v_TimeStamp value. Does Bulk Edit need something besides EditRecord to reference a field? Here's the code I've got: <SCRIPT LANGUAGE="JavaScript"> /* Declaration and initialization */ Stamp = new Date(); var v_TimeStamp; Hours = Stamp.getHours() Mins = Stamp.getMinutes(); /* Attach a prefix with digit '0' if the minutes is less than 10. */ if (Mins < 10) { Mins = "0" + Mins; } /* Construct the value of the v_TimeStamp variable in the format m/d/yyyy hh:mm */ v_TimeStamp=('' + (Stamp.getMonth() + 1) +"/"+Stamp.getDate() + "/"+Stamp.getFullYear() + ' ' + Hours + ":" + Mins); /* Field name - Date_Charge is referred with a prefix - EditRecord */ document.getElementById("EditRecordComments_Actual_Read_Date").value = v_TimeStamp; </SCRIPT> EDIT: Ah, I found a post showing you use 'BulkEdit' instead of 'EditRecord' but now the issue is if js is used to populate the Bulk Edit field it doesn't check the left column 'select' box automatically so the user has to do it manually. This defeats the purpose and is clunky. Is there a way to 'select' the field in Bulk Edit using js?
  5. Whenever I need something that happens in a Caspio datapage to 'exit' the datapage and do something on the host page I do it via calling a js function that affects the host page. For example, on the dropdown's 'change' you can call a js function (which can be located on the host page in script), and that function can do something like shows/hide a divs on the host page. So if you have images in divs on the host page, using an id for each div, you can show/hide the div's id, depending on the value of the Caspio dropdown (which runs an onChange event to get the value, which then runs a specific function on the host page. This is a general answer as there are many ways to do it, but basically a) use onChange script in the datapage to read the new dropdown's value b) depending on that value call a js function c) that function can be in script on the host page and can then do anything you want on that page (show/hide divs, etc.).
  6. Hi, I'm trying to use the code below in the footer of a tabular report results section for the 'Inline Add New Record' can use it. The js is code to get the user's computer date/time (not the localization or CB system) and put it in a date/time field. I use this code in submission forms with no issues but don't know how to reference it correctly for a tabular inline add new record. If someone knows how to mod this I'd really appreciate it. <SCRIPT LANGUAGE="JavaScript"> /* Declaration and initialization */ Stamp = new Date(); var v_TimeStamp; Hours = Stamp.getHours() Mins = Stamp.getMinutes(); Secs = Stamp.getSeconds(); /* Attach a prefix with digit '0' if the minutes is less than 10. */ if (Mins < 10) { Mins = "0" + Mins; } /* Construct the value of the v_TimeStamp variable in the format m/d/yyyy hh:mm */ v_TimeStamp=('' + (Stamp.getMonth() + 1) +"/"+Stamp.getDate()+ "/"+Stamp.getFullYear() + ' ' + Hours + ":" + Mins + ":" + Secs); document.getElementById("InsertRecordComments_Actual_Submission_Date").value=v_TimeStamp; </SCRIPT> EDIT: just found the solution right after posting this. In case anyone needs it, tabular inline add uses 'InlineAdd' instead of 'InsertRecord'. Wish everything was so easy!
  7. Hmmn, that's odd--I'll have to test it without the function. Basically, f_copy_print_address is used to copy the value of the Virtual drop down into the Text Area box. It's something Caspio set up several years ago for me to copy Text64000 values (addresses, at the time) that I've used for other Text Area copying. Not sure why it would hang the whole thing up but I'll do some tests to see, and perhaps there's a better way to copy the value to the Text Area. Thanks for pointing that out. EDIT: On testing it seems like the issue is that, for the warning message to run, you have to manually type something into the box. If the formula runs and pastes in some data via js then it doesn't 'register' the next time the onChange runs so v_spec won't be != "" and therefore no warning message. Last edit: the code below is what I ended up using and it works well, even though the js pasted data isn't registered a v_spec. This is because in this particular use I only need the warning to show if the user has actually typed something in. If the user just switches templates (values in the Virtual dropdown) it doesn't matter if what's there is overwritten, so there's no need for a warning message in those cases. Here's the code, if anyone else needs this and thanks, TellMeWhy, for taking a look. <script> $("[name='cbParamVirtual20']").change(function(){ var v_spec= document.getElementById("InsertRecordExtraDescriptionSpec").value; if(v_spec != "") { var retVal = confirm("Any data in the Specs box will be overwritten. Do you want to change templates?"); if (retVal == true) { f_copy_print_address('cbParamVirtual20', 'cke_InsertRecordExtraDescriptionSpec'); return true; } else { return false; } } if(v_spec == "") { f_copy_print_address('cbParamVirtual20', 'cke_InsertRecordExtraDescriptionSpec'); } }); </script>
  8. Hello, In a Submission form I've got js running on a Virtual field dropdown, OnChange, that updates a Text Area field (using a formula). The user may use this Virtual dropdown and update the Text Area, type some more data into it, and then change their mind and choose another option from the Virtual field drop down, which would run the onChange code again. I need is to put up a warning message with Cancel to let the user know the data already in the Text Area field will be overwritten if they choose OK. The issue is I don't want the message to show if the Text Area is blank (like when the form is first opened) because there's no data to be overwritten and the warning would be an annoyance. So the code needs to, when the Virtual Dropdown is changes, check to see if the Text Area field has any data or not. But I can't seem to reference the Text Area field's value after it's been updated by the js. Basically, the js needs to check to see if there's a value in the Text Area and, if so, run the warning. If there's no value then just run the formula. <script> $("[name='cbParamVirtual20']").change(function(){ var v_spec= document.getElementById("InsertRecordExtraDescriptionSpec").value; if(v_spec != "") { var retVal = confirm("Any data in the Specs box will be overwritten. Do you want to change templates?"); if (retVal == true) { f_copy_print_address('cbParamVirtual20', 'cke_InsertRecordExtraDescriptionSpec'); return true; } else { return false; } } if(v_spec == "") { f_copy_print_address('cbParamVirtual21', 'cke_InsertRecordExtraDescriptionSpec'); } }); </script> It seems like the line var v_spec= document.getElementById("InsertRecordExtraDescriptionSpec").value; isn't getting the current value if the user has already run this function. Any ideas on how this could be fixed?
  9. @kpcollierIt's been awhile since I posted this but I believe the issue can be fixed in the Tables Relationships view. When you create a relationship with a table it allows you to choose a display value instead of the Id. When you use that field in an inline edit datapage it will then use the display field for the user (while storing the id field) when editing. See the screenshot. Hope this helps-
  10. I just found this suggestion--this is ace! I hadn't thought of this workaround and it solves the very poor 'hourly' limit on Tasks. Thanks for posting PrinceZuko!
  11. Ok, after trying tons of stuff I finally came up with the answer, in case anybody needs to pull tabular, inline values from Caspio and use them in javascript. First, create a div with an id that uses the unique identify Caspio field: <div style="width:100%;text-align:right;" id='mydiva[@field:HProjectID]'></div> Then use some script with an EventListener to grap the current value in the div and use it as a parameter in some javascript. I have the js running in the a link. Whatever is in the div inside the EventListener function will show up in the above div. I use a calculated field for the 'label' because not all records need this link. If the record doesn't need it, the link doesn't show up and it keeps the results clean. This works really nicely. <script type="text/javascript"> document.addEventListener('DataPageReady', function (event) { document.querySelector("#mydiva[@field:HProjectID]").innerHTML =`<div style="width:100%;text-align:right;" > <a class="nou" style="font-size:13px;" href="#" onclick="document.getElementById('tracking').src = 'notify-actify/dash-notify?HProjectID=[@field:HProjectID]';">[@calcfield:4]</a> </div>`; }); </script>
  12. This code will run when the button is clicked (button id ="alertsbtn") and it will get the first value in the record set, and then cycle through all records. It doesn't get a value if the button in a record that's not the first is clicked. So it seems like this is fairly close to working, if someone can figure out the adjustment I'd really appreciate it. ** I have an alert box running to test the code, instead of the full code. <script type="text/javascript"> document.getElementById("alertsbtn").addEventListener("click", function(){ var isi = document.querySelector("#visi[@field:HProjectID]").innerHTML; var param_label = "?HProjectID="; var url_end = param_label + isi; alert(url_end); }); </script>
  13. Hi CooperBackpack, Many thanks for the code--I was thinking it would be something like using innerHTML but didn't know how to implement it. Now it will read a value for @field:HProjectID but it's giving the same number '3' for each record. So it seems like it's not catching each row's (record) individual HProjectID value. Am I missing something else? EDIT: it's odd because the <span> shows the correct HProjectID value so it is getting that. The issue is the variable 'isi' doesn't seem to be picking it up, instead pulling a random value '3'. 2nd EDIT: I think the answer lies somewhere with using addEventListener (see below- I'm using an alert box to test it). When this code is put in the html block it will, on datapage open, cycle through every HProjectID and show them in an alert box --correctly. So it's getting the right values. Now I just need to figure out how to run this code ONLY when the button/link is clicked. I've tried putting "function ifrtrack" in various parts of this code but so far can't get it to work. If there's a way to run this code ONLY when the button with onclick="ifrtrack" is clicked I think that would complete the issue. <script type="text/javascript"> document.addEventListener('DataPageReady', function (event) { var isi = document.querySelector("#visi[@field:HProjectID]").innerHTML; var param_label = "?HProjectID="; var url_end = param_label + isi; alert(url_end); }); </script>
  14. Hi, Does anyone know how, in a tabular datapage's results, to get a record's value and use it as a parameter in a javascript function that sets the source for an iframe on the host page? I have a link/button to run a js function in an html block in the tabular results (meaning each record has that link, so if there's 20 records there's 20 of the same links/buttons, one in each row): <input class="buttonlink" type="button" onclick="ifrtrack()" value="Reports" /> I have this code in the datapage's footer. It resets the source for an iframe (id="tracking") on the host page. This function is run when the user clicks the above link/button in a record's html block. <script> function ifrtrack() { document.getElementById('tracking').src = 'notify-actify/dash-notify'; } </script> The issue is that each record in the results has a specific ID value I need to pass as a parameter for the iframe source link. Meaning instead of .src = 'notify-actify/dash-notify' I need to have .src = 'notify-actify/dash-notify?HProjectID=[@field:HProjectID]'. The problem is that each record in the tabular results will have a different, unique 'HProjectID' value. One record might have HProjectID=8 (so the iframe source url would be 'notify-actify/dash-notify?HProjectID=8') while another record in the results might have HProjectID=221 (so the iframe source url would be 'notify-actify/dash-notify?HProjectID=221'). Looking at it now, It seems like you would use an anchor ID and then run the js in the same html block (instead of in the footer). Something like: <a id="visi[@field:HProjectID]"> <script type="text/javascript"> function ifrtrack() { var isi = document.getElementById("visi[@field:HProjectID]"); var param_label = "?HProjectID="; var url_end = param_label + isi; document.getElementById('tracking').src = 'notify-actify/dash-notify' + url_end; } </script> But this isn't pulling the value for HProjectID. I tested it with an alert for the variable isi and it just shows up blank. Soooo... I don't know how to a) get the HProjectID value for the specific record/row the user clicks the link/button on and b) how to incorporate that into the js function as a parameter value at the end of the iframe source url. If anyone knows how to do this that'd be really great and thanks in advance-
  15. Hi LittleMsGinger, Thanks for the help with this. I did find the Current Week criteria and that does work well to bring up the current week. The problem is that the user might want to scroll before weeks and I think that locks you into the current week. If there's a way to have it open to the current week as per above but then be scrollable, by the week, to previous weeks, that's what I need. Thanks again for the help, though, much appreciated!
  16. A couple years later--just want to say this is perfect and really helpful- thanks for posting it.
  17. Ok I finally figured it out, if anyone needs this solution in the future. The first post in this thread shows how to dynamically update the source of an iframe in a new window, in a new tab, but I needed to do this in the same tab and the js code kept getting wiped out when the new location was opened (I tried to append script to the new page's head, etc. but never could get it to work). So the solution to opening a new location/datapage in the same tab and dynamically setting the source for an iframe is to use Caspio's unique abilities in conjunction with regular js/html. Sometimes it's a lot simpler using Caspio in a hybrid scenario, deceptively so. Passing a parameter that tells the new page what js function to run is the way to do it, simpler than the complicated solution I thought was required. In a dropdown menu in a datapage use a link like <a href="newpage/dashboard?ProjectID=[@field:ProjectID]&ifr=ti" target="_self">Time Tracking</a> This will send a parameter called 'ifr' to the new page (same tab) with a value of 'ti' (for 'Time'). Standard Caspio stuff. Then in the datapage that opens in the new webpage (same tab) you catch the 'ifr=ti' as an external parameter in a Virtual field. In that same datapage, in the header use code to get that Virtual field's value and run a function that calls the code/function that actually changes the iframe's source. <script type="text/javascript"> document.addEventListener('DataPageReady', function (event) { var v_ifr = document.getElementById("cbParamVirtual1").value; if (v_ifr == "t") { setTimeout(function() { ifrtasks(); }, 500); } if (v_ifr == "cal") { setTimeout(function() { ifrcalendar(); }, 500); } if (v_ifr == "ti") { setTimeout(function() { ifrtime(); }, 500); } } }); </script> I use the SetTimeout function to delay calling the code half a second so that the rest of the page loads (there are a couple datapages hosted on the destination html page that has the iframe in it and I want them to load before the frame changes sources). In the above code, the datapage registers the 'ifr' value (that the menu link sent) and selects which function to call. If the 'ifr' value is 'ti' it calls a function called 'ifrtime'. That function is actually in the host html page itself (see below for why) but you could have it here in the datapage, if you want to. One of the things I've learned with Caspio is there's a lot of transference between datapages and the host html site for js and css and such, back and forth- meaning you can call a function from a datapage that is actually on the host page or in the site's js file. This gives a great amount of flexibility. So the actual code for changing the iframe source (located in the host page itself) is: <script type="text/javascript"> function ifrtasks() { var params = window.location.search; document.getElementById('ifr').src = '../project-dashboard-tasks' + params; document.getElementById("tasks").focus(); } function ifrcalendar() { var params = window.location.search; document.getElementById('ifr').src = '../project-dashboard-calendar' + params; document.getElementById("events").focus(); } function ifrtime() { var params = window.location.search; var loca = "&timelink=pd"; var urlend = params + loca; document.getElementById("time").focus(); document.getElementById('ifr').src = '../project-dashboard-time' + urlend; } </script> And the function 'ifrtime' is called and that updates the iframe source (and some other stuff, like setting a button's focus that looks like a tab). **To get iframes to really work with Caspio you need to be able to solidly pass parameters from the host page to the source datapage in the iframe. The way to do this is via code in the host page. It gets the 'structure' of the host page when it loads, including any parameters, and makes it available to js, which can then be passed onto the iframe's source datapage (via the variable called 'params). <script> window.addEventListener('DOMContentLoaded', (event) => { console.log('DOM fully loaded and parsed'); var params = window.location.search; }); </script> So that's how the parameter from one Caspio datapage is sent to another host page in new location in the same tab, then transferred to an iframe's source datapage. If you use the whole scenario above you can have dropdown menus all over your app that open different datapages (each hosted on a unique html page) in a single iframe on one host page. This can give a really rich, intuitive experience for the user, if done right. Long story short, I posted this whole scenario because it's one of the things that really unlocks a lot of what's special about Caspio and I wish I'd known this when I started building my app. I hope others can use this kind of thing for their own purposes. Once you realize how to use Caspio, and that you must think about design differently, it can be really powerful.
  18. I updated the original post with a closer, better solution and so have deleted this post.
  19. I've got a dropdown menu that I need the links to run a function in order to open a new window (in '_self') and then change that new window's iframe source (same domain as parent). I'm calling the function from a linked js file that runs the code correctly but ONLY if the new window is opened in a new tab. I've seen a lot of posts about how to transfer the js function to the new window but none of them if it's opened '_self'. Here's what I have so far (It's on a test server right now, hence the 127 address for the js file): function newWindow() { var win = window.open('projects/project-dashboard','_self'); win.document.head.innerHTML = '<title></title></head>'; win.document.body.innerHTML = '<body></body>'; var script = document.createElement('script'); script.type = "text/javascript"; script.src = 'http://127.0.0.1:9090/js/projnav.js'; win.document.head.appendChild(script); } The file js/projnav.js has a function that needs to run in the new window, and it does but only when opened in '_blank'. Does anyone know how to modify this to run the projnav.js function if the new window is opened in the same tab? Any help with this would be really appreciated!
  20. Just figured this out, if anyone needs it. Was simpler than I thought, just remove the button's onclick fucntion lines: <script type="text/javascript"> var width = 1100; var v_href= "http://127.0.0.1:9090/shortcuts/universal-item-search2?"; parent.$.fancybox.open({ closeBtn:false, openEffect : 'none', closeEffect : 'none', modal:true, type:'iframe', autoSize:true, width:width, href:v_href }); </script>
  21. Hello, I can't figure out the right syntax for this jquery code to run automatically after submission/update. It runs now (in the datapage footer) when the Submit button is clicked (it opens a FancyBox) but I need it to run after submission by a slight delay. The reason is that on Submit table A runs a trigger that updates table B and the FancyBox (opens another datapage in an iFrame) uses table B. Sometimes the FancyBox opens too fast, before the trigger has updated table B, and so it doesn't show the latest value. I figure if the code that opens the fancybox runs in the Destination after submission it would be enough of a delay for the trigger to run behind the scenes. I just don't know how to change the code so that it runs automatically in the Destination (message) after submission. Here's the current code, it's activated by a submit button with an id="openfb". I need it to run automatically in the Destination, after submission- any help would be great! <script type="text/javascript"> $("#openfb").on('click', function() { var width = 1100; var v_href= "http://127.0.0.1:9090/shortcuts/universal-item-search2?"; parent.$.fancybox.open({ closeBtn:false, openEffect : 'none', closeEffect : 'none', modal:true, type:'iframe', autoSize:true, width:width, href:v_href }); }); </script>
  22. I figured this out, if anyone else needs it. Basically, I have a button that uses the class to call the fancybox code but also an onclick that calls the submit code separately. This way both of the functions work in sequence. Here's the button: <button class="cbpop btaction" href="#" data-width="1100" data-href="../shortcuts/universal-item-search" onclick="myFunction()"><i class="fa fa-search fa-lg"></i></button> And here's the script in the datapage footer. I have the Destination set to 'Same Form.' Note that the code opens the fancybox in the parent as this datapage is embedded in an iframe. <script> $('.cbpop').each(function(index, el){ var width = 450; var v_href= $(el).attr('href'); if (v_href=="#") { v_href=$(el).attr('data-href'); } if($(el).attr('data-width')){ width = $(el).attr('data-width'); } parent.$(el).fancybox({ closeBtn:false, openEffect : 'none', closeEffect : 'none', modal:true, type:'iframe', autoSize:true, width:width, //href:$(el).attr('href') href:v_href }); }); </script> <script> function myFunction(){ setTimeout('document.forms["caspioform"].submit()',1000); } </script>
  23. Actually, I have a button that runs a version of the above code to open the fancybox. All I need to do now is make the form submit/update after the the fancybox is initiated (or before but I think that'll end the code running so the fancybox won't initiate). Does anyone know how/where to put code into this to submit the form? <script> $('.cbpop').each(function(index, el){ var width = 450; var v_href= $(el).attr('href'); var v_keyword= document.getElementsByName("EditRecordKeyword")[0].value; var v_key= "?key="; var v_urlend = v_key + v_keyword; if (v_href=="#") { v_href=$(el).attr('data-href'); } if($(el).attr('data-width')){ width = $(el).attr('data-width'); } $(el).fancybox({ closeBtn:false, openEffect : 'none', closeEffect : 'none', modal:true, type:'iframe', autoSize:true, width:width, //href:$(el).attr('href') href:v_href + v_urlend }); }); </script>
  24. Hi, I have a Details (or single record update, haven't decided yet) form that, when updated, I need to open a fancybox that brings up another web page. The Details/Single-Rec-Update form would ideally be set to 'Same Form' for destination but I think I need to use Message in order to put code in. The below code is taken from what I'd been using with a button to open the fancybox but with the data-href put in (whereas the button would put that in before). Does anyone know what mods need to be done to this code for it to work (open a fancy box with a new web page after submission/update)? <script> var width = 450; var v_data-href="../shortcuts/universal-item-search"; var v_href= $(el).attr('href'); if (v_href=="#") { v_href=$(el).attr('v_data-href'); } if($(el).attr('data-width')){ width = $(el).attr('data-width'); } $(el).fancybox({ closeBtn:false, openEffect : 'none', closeEffect : 'none', modal:true, type:'iframe', autoSize:true, width:width, //href:$(el).attr('href') href:v_href }); </script>
×
×
  • Create New...