gratuity will not be released unless all prior dues are cleared with the bank and the organisation you are working. so you cannot get the gratuity before clearing the loan.