Fetching Data from another doctype using custom script via salary slip creations

HI Good Day i want to automatically fetch the data once i create salary slip under payroll entry. how can i do this via custom script… in the sample image shown this custom script works when i create salary slip manually… but when i create salary slip under payroll entry it doesnt fetch the data. kindly see the images below for reference.

Thank you