getFormContext (Client API reference)
Returns a reference to the form or an item on the form depending on where the method was called.
Syntax
ExecutionContextObj.getFormContext()
Return value
Type: Object
Description: Returns a reference to the form or an item on the form such as editable grid depending on where the method was called. This method enables you to create common event handlers that can operate either on a form or an item on the form depending on where its called.
Example
The following sample code demonstrates how you can create a method that sets notification on a form column or editable grid cell depending on where you registered the script (Column OnChange event or editable grid OnChange event):
function commonEventHandler(executionContext) {
var formContext = executionContext.getFormContext();
var telephoneAttr = formContext.data.entity.attributes.get('telephone1');
var isNumberWithCountryCode = telephoneAttr.getValue().substring(0,1) === '+';
// telephoneField will be a form control if invoked from a form OnChange event;
// telephoneField will be a editable grid GridCell object if invoked from editable grid OnChange event.
var telephoneField = telephoneAttr.controls.get(0);
if (!isNumberWithCountryCode) {
telephoneField.setNotification('Please include the country code beginning with '+'.', 'countryCodeNotification');
}
else {
telephoneField.clearNotification('countryCodeNotification');
}
}
Related articles
피드백
https://aka.ms/ContentUserFeedback
출시 예정: 2024년 내내 콘텐츠에 대한 피드백 메커니즘으로 GitHub 문제를 단계적으로 폐지하고 이를 새로운 피드백 시스템으로 바꿀 예정입니다. 자세한 내용은 다음을 참조하세요.다음에 대한 사용자 의견 제출 및 보기