New I797 Recieved while having a h1b visa stamping appointment on old I797

Hello

I had booked a h1b Stamping appointment based on my I 797 that was valid till July 2023. My appointment is in Canada in May. However, I applied for an extension and just received the approval. Can I change the details on my old DS160 and Appointment to reflect the new Petition Number?

Yes, just go ahead and submit a new DS-160 with the reference to new I-797 and carry copy of old and new DS-160 to your interview along with other supporting documents.