Query regarding PIH in XML

While submitting Standard invoice, which previous invoice hash(PIH) needs to be used in XML for next invoice? Do we need to use hash we get from zatca after submitting invoice or we need to generate our own hash each time before submitting invoice or is there anything else ?
Also do we need to maintain order of hash incase previous invoice is rejected ?

After successful clearance by Zatca, the invoice hash remains unchanged. However, you need a QR code. If you are developing on the .Net environment, let me know and I will give you the appropriate code.