Forum Discussion

RyanStanford1's avatar
RyanStanford1
Qrew Captain
6 years ago

Mobile App version of kRid, Record ID

Good Afternoon,

I know in JavaScript on the desktop browsers there is a global variable kRid which will give the Record ID of the current page... However global variables are not the same in the app.

I've been getting around this with implementing buttons and passing the [Record ID#] as a dataset in the button url...

I'm trying to do a true "onload" execution, and it needs to work via app. Has anyone been able to figure it out how to accomplish this?

My usecase is I want to take the record ID, and query to see if there's a related child record.

------------------------------
Ryan Stanford
------------------------------

4 Replies

  • Ryan,

    For IOL mobile, use this in a rich text field and change moduleone.js to your code page name. I'm not sure yet if there is a global variable on mobile that we can grab and use, I'll keep poking around. 

    "<img qbu=\"module\" src=\"/i/clear2x2.gif\" " &
    "onload=\"javascript:if(typeof QBU=='undefined'){QBU={};$.getScript('" &
    URLRoot() &
    "db/" &
    Dbid() &
    "?a=dbpage&pagename=moduleone.js&rand='+Math.random())}\">"​

    Read Dan's post, he does a good job explaining
    Mobile IOL

    ------------------------------
    Everett Patterson
    ------------------------------
    • RyanStanford1's avatar
      RyanStanford1
      Qrew Captain
      I apologize, let me clarify... I'm executing mobile IOL perfectly fine, aside from discerning how to get the record ID of the page. I kinda of feel like 90% of the work I do is tied to Dan Diebolt's posts in one way or another.

      ------------------------------
      Ryan Stanford
      ------------------------------
      • EverettPatterso's avatar
        EverettPatterso
        Qrew Captain
        I was able to get it on Mobile from this, but only if I refresh . The first time load is not running the script. 

        (function() {
        var myRid = $('.formContainer').attr('data-rid');
        alert('RecordID is ' + myRid);
        })();


        ------------------------------
        Everett Patterson
        ------------------------------
  • I have a, what I think, to be a clunky solution, but it does work... Basically it checks for the global variable on desktop, gets the formContainer like you suggested, and I also have where it can be in the URL....

    var RecID
    try{RecID = kRid;}catch{}
    if(!(RecID)){
    try{RecID = parseInt( new URLSearchParams(window.location.search).get('rid'))}catch{}
    }
    if(!(RecID)){
    try{RecID = parseInt(document.getElementsByClassName('formContainer')[0].getAttribute('data-rid'))}catch{}
    }

    ------------------------------
    Ryan Stanford
    ------------------------------