AppAPI users को FormEngine और DMView में विभिन्न methods का उपयोग करके app से system meta data load करने की अनुमति देता है। यह app से विशिष्ट जानकारी प्राप्त करने के लिए विभिन्न data keys तक पहुँच प्रदान करता है।

xlsform में, आप निम्नलिखित syntax के साथ pulldata() function का उपयोग कर सकते हैं:

  • 'app-api': यह keyword FormEngine को App API से data load करने के लिए सूचित करता है।
  • 'data-key': यह वह key है जिसका data आप App API से load करना चाहते हैं।
  • यदि data key अमान्य है या समर्थित नहीं है, तो calculation “n/a” return करेगी।

App-API के साथ उपयोग किए जा सकने वाले supported data keys यहाँ दिए गए हैं:

osPlatform: वर्तमान OS का नाम (Android या iOS) और OS version return करता है। Web platforms एक empty value return करेंगे।

appPlatform: app platform का नाम return करता है, जो rtSurvey है।

appVersion: app का version name return करता है।

getDisplayWidth: device screen की चौड़ाई pixels में return करता है।

getDisplayHeight: device screen की ऊँचाई pixels में return करता है।

getScreenSize: device screen का आकार inches में return करता है।

projectCode: वर्तमान project code return करता है जिस site पर user sign in कर रहा है।

projectURL: वर्तमान project URL return करता है जिस site पर user sign in कर रहा है। default/fallback मूल्य empty text ("") है।

startingPoint: वह path return करता है जो form शुरू करने वाला point है। अधिक जानकारी के लिए “Form starting point” देखें।

serverTime: server पर date और time का सर्वोत्तम उपलब्ध approximation return करता है।

user.[attribute]: निर्दिष्ट attribute key के आधार पर वर्तमान user attributes return करता है। उपलब्ध attribute keys के लिए “User attributes” table देखें।

वर्तमान user जानकारी प्राप्त करने के लिए pulldata() params में “user.” के साथ नीचे दिए गए attribute keys को combine करें। उदाहरण के लिए, user.username, user.email, आदि का उपयोग करें।

Attribute Keyविवरण
usernameUser का username
nameUser का पूरा नाम
staffCodeUser का staff code
phoneUser का phone number
emailUser का email address
descriptionUser information में description text
organization_idजिस Organization ID से user संबंधित है
organization_nameजिस Organization name से user संबंधित है
team_idजिस Team ID से user संबंधित है
supervisor_idUser के supervisor का ID
is_supervisorयदि user supervisor है तो 1, अन्यथा 0

instancePath: वर्तमान instance folder path return करता है।

appLanguage: app की settings में set वर्तमान app language return करता है (जैसे vi, en)।

openArgs.[attribute]: ActionButton (act_fill_form, act_get_instance) से पास किया गया open-form-argument return करता है। default/fallback मूल्य empty text ("") है।

primaryAppColor: app का primary color retrieve करता है।


उपयोग के उदाहरण

गणनाकर्ता का username और organisation संग्रहीत करना

typenamelabelcalculation
calculateenumerator_namepulldata('app-api', 'user.name')
calculateenumerator_orgpulldata('app-api', 'user.organization_name')
calculateenumerator_emailpulldata('app-api', 'user.email')

audit purposes के लिए इन्हें note labels में उपयोग करें:

  note | interviewer_info | Interviewer: ${enumerator_name} (${enumerator_org})
  

Device और screen की जानकारी

typenamelabelcalculation
calculatedevice_platformpulldata('app-api', 'osPlatform')
calculateapp_verpulldata('app-api', 'appVersion')
calculatescreen_wpulldata('app-api', 'getDisplayWidth')

Troubleshooting के लिए उपयोगी: यह पहचानने के लिए कि प्रत्येक submission के लिए कौन सा device version उपयोग किया गया था, अपने data के साथ device_platform और app_ver export करें।

Device time के बजाय Server time

Device clocks गलत हो सकते हैं। अधिक reliable timestamp के लिए serverTime का उपयोग करें:

typenamelabelcalculation
calculateserver_tspulldata('app-api', 'serverTime')

User role के आधार पर Conditional logic

केवल supervisors को एक supervisor-only section दिखाएं:

typenamelabelrelevant
calculateis_supervisorpulldata('app-api', 'user.is_supervisor')
begin_groupsupervisor_sectionSupervisor review${is_supervisor} = '1'
textsupervisor_notesSupervisor notes
end_group

Action button से arguments पास करना

जब form को custom arguments के साथ act_fill_form action button से launch किया जाता है:

typenamelabelcalculation
calculatepassed_hh_idpulldata('app-api', 'openArgs.household_id')
calculatepassed_taskpulldata('app-api', 'openArgs.task_code')

action button को matching keys (जैसे household_id, task_code) के साथ arguments पास करने होंगे।

Project की जानकारी का उपयोग करना

typenamelabelcalculation
calculateprojectpulldata('app-api', 'projectCode')
calculateproject_urlpulldata('app-api', 'projectURL')

Notes

  • सभी pulldata('app-api', ...) calls form खुलने पर evaluate किए जाते हैं और session के दौरान dynamically re-evaluate नहीं होते (सिवाय serverTime और now() के)।
  • यदि कोई key unsupported है या data उपलब्ध नहीं है, तो function 'n/a' return करता है (empty string नहीं — != '' के बजाय != 'n/a' से test करें)।
  • openArgs values केवल तभी उपलब्ध होती हैं जब form को action button से launch किया जाता है; अन्यथा वे empty string return करती हैं।
क्या यह पृष्ठ सहायक था?