Can you try this and see if it works?
function getTextFieldValue() {
// Get the parent resource of the current resource
var parentResource = this.getCurrentResource().getParent();
// If the parent resource exists, get its parent resource
if (parentResource) {
var grandParentResource = pa...