Get a field value for html page?

  • 0
  • 1
  • Question
  • Updated 6 months ago
  • Answered
I'm trying to set the value of an input on a popup html page onload using the value in a form field. But all i'm getting is this: "[object Object]"
 


code:

<script>
var timg = window.opener.$("#_fid_43");
 $("#imgurl").val(timg);
</script> 



I've tried a few different things, but end with that same result.
fid_43 is a Formula- Rich Text field that gives the image url for a record.

Any ideas how to get that URL into that input?
Photo of Chad Brandmire

Chad Brandmire

  • 968 Points 500 badge 2x thumb

Posted 6 months ago

  • 0
  • 1
Photo of Scott

Scott

  • 314 Points 250 badge 2x thumb
Howdy Chad,

Is this [object Object] field only used on a single record?  Or does it need to be dynamic based on a specific record?

As of now, QB has no way of knowing what table or record it should look on for fid 43.  Permalinking is out of the question?
Photo of Scott

Scott

  • 314 Points 250 badge 2x thumb
Gotchya.  Take a look at my reply below-  I think it may help.  You can accomplish this with jQuery, but on a stand-alone code page, the jQuery will have no idea what #_fid_43 means, you have to provide it with an actual link, perhaps utilizing the API. 
Photo of Chad Brandmire

Chad Brandmire

  • 968 Points 500 badge 2x thumb
I've played around with a couple of api methods. My problem with the api is how does my html page get the rid for the query? 
Photo of Scott

Scott

  • 314 Points 250 badge 2x thumb
Ok, that's a solvable issue.  Is the button that triggers the pop-up a usermade button? Or is it native quickbase?

It will have to be a userbased button, so you can pass a variable over to the pop-up, which then jQuery can utilize.  

For example, in the pop-up button you can end the url with &rid=[Record ID#]

And then you can have Javascript like so
var rid = urlParam('rid');
Simple!

(Let me know if you're able to get this one working)
(Edited)
Photo of Chad Brandmire

Chad Brandmire

  • 968 Points 500 badge 2x thumb
Params!!!

No api needed. just loaded my formula field in there.

<script>
var url_string = window.location.href;
var url = new URL(url_string);
var img = url.searchParams.get("img");
console.log(img);
$("#imgurl").val(img);
</script>

Thanks!
Photo of Scott

Scott

  • 314 Points 250 badge 2x thumb
Woo!  Glad I was able to help you out, even if I didn't directly solve your issue.  :^)
Photo of Scott

Scott

  • 314 Points 250 badge 2x thumb
Replying to myself here:

You can utilize API_GetRecordInfo for this, should you have all the prerequisites.. (RecordID & DBID)

https://<DOMAIN>.quickbase.com/db/<DBID>?a=API_GetRecordInfo&rid=<RID>&apptoken=<APPTOKEN>

You'll then have to parse out the response for the specific _fid_ you're looking for, and you can return those results.

Let me know if this helps at all. 
(Edited)