Help

Re: Add record from released custom block

2209 0
cancel
Showing results for 
Search instead for 
Did you mean: 
francisco_silv1
4 - Data Explorer
4 - Data Explorer

i have button to add record. before release , in development ,was able to add record from custom block succesfully with `table.createRecordAsync’ . when block is released does not add new record. block is started on terminal

7 Replies 7

Can you add a screenshot (including the browser console) to share any errors when your released block tries to create a record?

attached .

add rec1.png

Is there any error inside the block or in the developer console after you click “Add marker”?

No error in block or console .

Hm, this is going to be tricky to figure out without seeing the code of the block. If this is an open source block, can you link to the repo? Otherwise can you paste the relevant files (i.e. the component that has the “Add marker” button and the onClick handler code)

Emma_Yeap
Airtable Employee
Airtable Employee

Adding on to Kasra’s suggestions: one common cause of the “it works in development, but not after releasing” is that you’re relying on globalConfig values that were set in development, but haven’t been set in the release block yet (they have separate globalConfig stores).

This seems like it might be happening here since your omdbApiKey is undefined - is it stored in globalConfig?

To test this theory, you can clear your globalConfig in development from the block developer tools and see if the same issue occurs.

There’s more details in this previous forum thread and the “Polishing your block” guide.

yes found the issue i was missing id in airtable ui buttons. i got to fix by reverting to regular input button

function AddForm(props) {
const [name ,setName] = useState()

const [seaty, setSeatY] = useState()
const [isDialogOpen, setIsDialogOpen] = useState(false);

   const base = useBase();
   const table = base.getTableByName('Markers');
  const records = useRecords(table.selectRecords());

async function handleSubmit(e) {
const errors = {};
e.preventDefault()
if (!name){
// setName(“required”)
return ;
}
try {
//save record
table.createRecordAsync({‘Name’: name, ‘X’: seatx, ‘Y’:seaty});

  // marker
} catch (e) {
  console.log('error',e);
}
  setName("")
setSeatX("")
setSeatY("")

}
const handleSaveMarkerClick = () => {
setIsDialogOpen(true)
}
// const addRecord = (record, recordFields) => {
// if (table.hasPermissionToUpdateRecord(record, recordFields)) {
// // table.createRecordAsync(recordFields);

//         }

return (



Add marker
        {isDialogOpen && (
            <Dialog onClose={() => setIsDialogOpen(false)} width="320px">
                <Dialog.CloseButton />
               

                <Label htmlFor="my-input"></Label>
               <form onSubmit= {handleSubmit}>
                <legend>Add New Marker</legend>
                <div className="form-group">
                
                <Input value={name} onChange={e => setName(e.target.value)} id="Name" type="text" placeholder="Name"  />
                <label> Seat</label>
                <Input value={seatx} onChange={e => setSeatX(e.target.value)} id="seatx" type="text" placeholder="X" />
                <Input value={seaty} onChange={e => setSeatY(e.target.value)} id="seaty" type="text" placeholder="y" />
                <Button   
icon="edit">Add marker </Button>
              </div>
            </form>

                
                <Button onClick={() => setIsDialogOpen(false)}>Close</Button>
            </Dialog>
          )}
    </div>

)