Search Results for 'script'
-
Search Results
-
Hello everyone, I’ve been using Tap Forms for a few years and I recently downloaded the new Pro. In general, I’m liking it, although I’ve found some small problems. Specifically, I can’t organise my scripts numerically as I do in Tap Forms 5, nor can I change the font in List mode, although I can in the others. I would appreciate your help. Thank you very much and best regards.
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