Search Results for 'script'
-
Search Results
-
I’ve written this javascript to go out and grab sold ebay items and store then in my database. I can’t seem to get it to work. ChatGPT says it because: “Tap Forms JavaScript scripting engine does not have direct HTTP request capability (like fetch or XMLHttpRequest). Scripts are sandboxed and cannot reach out to the web directly.”
Is this true? Any suggestions on how to get this down if this is the case? I’d like to use the script on my Mac and iOS devices.
// Define Field IDs from the current form
const coinTypeFieldId = ‘fld-7b49d2da923f4e90a22c2c43d476504b’;
const yearFieldId = ‘fld-2196446daf504b619016cf97e293fa00’;
const mintmarkFieldId = ‘fld-81ea772bc0e24626977c0d2ddece998e’;// Defind Field IDs for the Coins on Ebay form
const Ebay_coin_type_id = ‘fld-1dcc89f4289e482c93cbc940fbe7ca09’;
const Ebay_mint_mark_id = ‘fld-1e874b9e81c94622837943a57654a563’;
const Ebay_year_id = ‘fld-2c3a9b6921084f909c69ac90b42335ea’;
const Ebay_price_id = ‘fld-20c6a1a5d6a74538acccd39458d8c61e’;
const Ebay_photo_id = ‘fld-e86d4deab234444db94a4b06e731e919’;
const Ebay_web_site_id = ‘fld-d77c51322b99468193c94ba823fca06b’;// Define the Forms
const coinsWantedForm = document.getFormNamed(‘Coins Wanted’);
const coinsOnEbayForm = document.getFormNamed(‘Coins on eBay’);// Get the current record
//const currentRecord = form.getRecord();// Get the coin search details directly from the record
const coinType = record.getFieldValue(coinTypeFieldId);
const year = record.getFieldValue(yearFieldId);
const mintmark = record.getFieldValue(mintmarkFieldId);// eBay API Setup
const EBAY_AUTH_TOKEN = ‘API TOKEN REDACTED’;const query =
${coinType} ${year} ${mintmark}
;// eBay Search URL
const url =https://api.ebay.com/buy/browse/v1/item_summary/search?q=Lincoln%20Penny%201909%20S&filter=sold_status:SOLD
;console.log(
Searching eBay for: ${query}
);// Async Fetch Wrapper for Tap Forms
async function fetchEbayData() {
try {
const response = await fetch(url, {
method: ‘GET’,
headers: {
‘Authorization’:Bearer ${EBAY_AUTH_TOKEN}
,
‘Content-Type’: ‘application/json’
}
});if (!response.ok) {
throw new Error(HTTP Error: ${response.status}
);
}const data = await response.json();
if (!data.itemSummaries || data.itemSummaries.length === 0) {
console.log(‘No eBay items found.’);
return;
}// Create Coins Wanted Record
const wantedRecord = coinsWantedForm.addNewRecord();
wantedRecord.setFieldValue(coinTypeFieldId, coinType);
wantedRecord.setFieldValue(yearFieldId, year);
wantedRecord.setFieldValue(mintmarkFieldId, mintmark);// Prepare link field array
const linkedEbayRecords = [];// Process each eBay item
for (let item of data.itemSummaries) {
const ebayRecord = coinsOnEbayForm.addNewRecord();
ebayRecord.setFieldValue(Ebay_coin_type_id, coinType)
ebayReocrd.setFieldValue(Ebay_year_id, year)
ebayRecord.setFieldValue(Ebay_mint_mark_id, mintmark)
ebayRecord.setFieldValue(Ebay_price_id, item.price.value);
ebayRecord.setFieldValue(Ebay_web_site_id, item.itemWebUrl);// Save all available photos
let allPhotos = [];// Add the main image
if (item.image && item.image.imageUrl) {
allPhotos.push(item.image.imageUrl);
}// Add additional images if available
if (item.additionalImages && item.additionalImages.length > 0) {
item.additionalImages.forEach(img => {
if (img.imageUrl) {
allPhotos.push(img.imageUrl);
}
});
}// Save all photos to the Photo field (must be a Photo field that accepts multiple items)
ebayRecord.setFieldValue(Ebay_photo_id, allPhotos);// Save all photos (only saves the featured photo)
// if (item.image && item.image.imageUrl) {
// ebayRecord.setFieldValue(‘fld-ebay-photo-id’, [item.image.imageUrl]);
// }linkedEbayRecords.push(ebayRecord);
}// Link eBay records to Coins Wanted
wantedRecord.setFieldValue(‘Coins on Ebay’, linkedEbayRecords);console.log(
Found and linked ${linkedEbayRecords.length} eBay items.
);} catch (error) {
console.error(‘eBay API Error:’, error);
}
}// Start the async function
fetchEbayData();Topic: Rating Star to Other Shape
Topic: Autofill advice
Hi,
I’m looking for some advice. I know just enough about scripting/programming to get myself in trouble.
I’m setting up a coin database. There will be a dropdown field for coin types (e.g., Lincoln Penny, Jefferson Nickel, etc.) and a separate field for denomination (e.g., 1 cent, 5 cent, 1 dime).
I’d like the denomination field to autofill based on the selected coin type. Some coin types will share the same denomination (e.g., both Lincoln Penny and Indian Head Penny = 1 cent).
What’s the best way to accomplish this—using a script, a calculated field, or something else?
Thanks!
Hey Brendan,
I’m really enjoying TF Pro. You have done an incredible job with all versions of TF. I’m proud to say I’m a long-time TF user. I guess it was probably around 2009ish I found TF on the App Store and fell in love with it. I was amazed at how I could have a fully functional and customizable database on my phone, especially right when the App Store was really just starting to get its footing. TF was way ahead of its time and still is. After a number of years I became a traitor and went to Android for a while. The whole time I was on Android I was chasing that TF experience in the Google Play store to no avail. When I came back to iPhone I snatched up TF5 and use it every day. Now I’m happy to upgrade to a Pro subscription and support an amazing app by an incredible developer.
The new features have been great and I have only ran into one issue so far. I have a form in TF that I use to track product reviews. One of the fields in my form is a Note field titled “Review”. In TF5 I configured this field so that it has a default value of the review template I created (ss attached). I upgraded from TF5 and imported my .tfarc file into TF Pro. When I go into the field options for my Review field in TF Pro and tap into the “Default Value” option the app crashes immediately. Is this something you’ve heard of happening before? Thanks a ton!
-Josh
Topic: Cascading Pick Lists
Is there a way to read/write to sub-levels in Cascading Pick Lists in scripts?