Application
// Get Theme
Application.getTheme();
Application.getTheme() SAP Analytics Cloud (SAC) scripting का function है, जो बताता है कि आपकी application या dashboard में इस समय कौन-सा theme (जैसे light, dark या custom theme) लागू है। Themes पूरे dashboard की look और feel को control करते हैं—जैसे colors, fonts, background और overall styling। यह function चलाने पर आपको current theme का name और उसकी details मिलती हैं। इसका उपयोग आप scripting में theme-based logic बनाने के लिए कर सकते हैं, जैसे यदि dark theme active हो तो कुछ widgets का color बदलना या layout adjust करना। इससे आपका dashboard अधिक dynamic और user-friendly बनता है।
// Get Teams Info
Application.getTeamsInfo();
Application.getTeamsInfo() SAP Analytics Cloud (SAC) scripting में इस्तेमाल होने वाला function है, जो यह बताता है कि वर्तमान user किन-किन teams का हिस्सा है। SAC में teams का उपयोग users को group करने और उनको shared access देने के लिए किया जाता है। जब आप यह function चलाते हैं, तो यह user से जुड़ी सभी teams की list और उनकी details देता है। इस जानकारी को आप scripting में use करके team-based visibility, access control या custom logic बना सकते हैं। उदाहरण के लिए, किसी specific team के users को अलग dashboard features दिखाना या particular data तक access allow करना।
// Get Roles Info
Application.getRolesInfo();
Application.getRolesInfo() SAP Analytics Cloud (SAC) scripting में इस्तेमाल होने वाला function है, जो वर्तमान user के roles की पूरी जानकारी देता है। जब यह function run होता है, तो यह बताता है कि user के पास कौन-कौन से roles assigned हैं, जैसे Admin, BI Content Creator, Viewer आदि। इससे आप scripting के अंदर condition लगा सकते हैं—उदाहरण के लिए, अगर user Admin है तो कुछ features दिखाएँ, और अगर Viewer है तो सीमित access दें। यह function security और user-level access control को manage करने में बहुत helpful है, क्योंकि यह आपको role-based customization करने की सुविधा देता है।
// Get mode
Application.getMode();
Application.getMode(); का इस्तेमाल यह check करने के लिए किया जाता है कि आपका SAP Analytics Cloud (SAC) analytic application अभी Edit mode में चल रहा है या View mode में।
- Edit Mode → आप layout बदल सकते हैं, widget जोड़ सकते हैं और design बदल सकते हैं।
- View Mode → End-user app के साथ interact करते हैं लेकिन design को edit नहीं कर सकते।
यह function मौजूदा mode को "VIEW" या "EDIT" जैसी value के रूप में दिखाता है।
यह तब मददगार होता है जब आप चाहते हैं कि कुछ action सिर्फ़ view mode में काम करें (जैसे filtering, navigation) या edit mode में कुछ button छिपाना चाहते हैं। यह आपके app को smart बनाता है और गलती से edit होने से रोकता है।
// Get width in pixel
Application.getInnerWidth();
Application.getInnerWidth(); आपके SAC application window की दिखने वाली width pixels में दिखाता है। इसका मतलब है कि यह मापता है कि tables, charts और input controls जैसे widget के लिए कितनी horizontal जगह उपलब्ध है। इसमें browser borders या scrollbar शामिल नहीं हैं—सिर्फ़ वह जगह जहाँ आपकी story या analytic app content दिखाया जाता है।
यह तब काम आता है जब आप अपने layout को responsive बनाना चाहते हैं। उदाहरण के लिए, आप उपलब्ध जगह के आधार पर chart का size अपने आप बदल सकते हैं, panels छिपा सकते हैं, या column की width adjust कर सकते हैं। अगर screen छोटी हो जाती है, तो आप widget को फिर से arrange कर सकते हैं। आसान शब्दों में, यह function आपको ऐसे app design करने में मदद करता है जो किसी भी screen size पर अच्छे दिखें।
// Get height in pixel
Application.getInnerHeight();
Application.getInnerHeight(); SAC application window की इस्तेमाल करने लायक height pixels में बताता है। इस value में browser toolbars, menu या scrollbar शामिल नहीं होते हैं और यह सिर्फ़ उस actual दिखने वाले area को मापता है जहाँ widgets दिखते हैं।
यह तब काम आता है जब आप responsive layouts बनाना चाहते हैं, widget size को automatically adjust करना चाहते हैं, या screen की height के हिसाब से elements का arrangement बदलना चाहते हैं। उदाहरण के लिए, आप मौजूद जगह के हिसाब से table या chart का size बदल सकते हैं ताकि वह बिना scroll किए एकदम सही fit हो जाए। यह function developers को ऐसे applications design करने में मदद करता है जो clean दिखें और अलग-अलग screen sizes पर अच्छे से काम करें।
// to get model id
Application.getInfo();
Application.getInfo(); का इस्तेमाल मौजूदा SAC analytic application के बारे में technical details पाने के लिए किया जाता है। जब आप यह command चलाते हैं, तो यह application ID, version, creation date, last modified date, author और दूसरे metadata जैसी जानकारी वाला एक object लौटाता है।
यह तब मददगार होता है जब आप debugging के लिए details log करना चाहते हैं, बदलावों को track करना चाहते हैं, या users को app की जानकारी दिखाना चाहते हैं (जैसे “About App” section)। Developers इसका इस्तेमाल testing के दौरान environment या version को verify करने के लिए भी करते हैं। यह function कुछ भी नहीं बदलता है; यह बस आपको analytic application के बारे में काम की background जानकारी देता है।
// to get active tab name
Application.getActivePage();
Application.getActivePage(); का इस्तेमाल यह पता लगाने के लिए किया जाता है कि SAC analytic application में अभी कौन सा page खुला है।
जब आप यह command चलाते हैं, तो यह active page का technical नाम बताता है (उदाहरण के लिए: "Page_1" या "SalesPage")। यह तब काम आता है जब आपके app में कई pages हों और आप user जो page देख रहा है, उसके आधार पर अलग-अलग script चलाना चाहते हों।
उदाहरण के लिए, आप widget दिखा या छिपा सकते हैं, खास filter load कर सकते हैं, या सिर्फ़ कुछ page पर ही action trigger कर सकते हैं। यह आपको navigation control करने और page-based logic को clean, dynamic और automated तरीके से manage करने में मदद करता है।
// to show busy indicator
Application.showBusyIndicator("Loading data...");
Application.showBusyIndicator("Loading data..."); एक SAP Analytics Cloud (SAC) scripting command है जिसका उपयोग Analytic Applications में screen पर एक display loading indicator display करने के लिए किया जाता है। यह users को सूचित करता है कि कोई प्रक्रिया, जैसे data refresh, filtering, या navigation, वर्तमान में background में चल रही है। Progress दर्शाने के लिए एक spinner के साथ "Loading data..." text display होता है। यह लंबे operations के दौरान confusion या बार-बार clicks को रोककर user अनुभव को बेहतर बनाता है। इसका उपयोग आमतौर पर उन actions से पहले किया जाता है जिनके पूरा होने में काफी समय लगता है, जैसे data actions execute करना, data sources को refresh करना, या एक नया page load करना।
// to hide busy indicator
Application.hideBusyIndicator();
Application.hideBusyIndicator(); एक SAP Analytics Cloud (SAC) scripting function है जिसका उपयोग पहले दिखाए गए busy या loading indicator को हटाने के लिए किया जाता है।
// print user name
var userName=Application.getUserInfo().displayName;
Text_1.applyText(userName);
यह script SAP Analytics Cloud (SAC) में logged-in user's का नाम display करती है और उसे एक text widget में दिखाती है। पहली line,
var userName=Application.getUserInfo().displayName;
User details तक पहुँचने के लिए getUserInfo() function का उपयोग करता है, फिर display नाम (जैसे "John Kumar") को userName नामक एक variable में store करता है। दूसरी line,
Text_1.applyText(userName);
उस नाम को लेता है और उसे Text_1 के रूप में पहचाने जाने वाले text widget के अंदर dynamic रूप से display करता है। यह dashboards को personalize करने, users का अभिवादन करने, या किसी Analytic Application के भीतर users interactions को track करने के लिए उपयोगी है।
// print current date
var currentDate= new Date();
Text_1.applyText(currentDate.toDateString());
इस script का उपयोग SAP Analytics Cloud (SAC) Analytic applications में वर्तमान date को dynamic रूप से display करने के लिए किया जाता है। पहली line,
var currentDate= new Date();
एक नया JavaScript Date object बनाता है जो उस समय user के system की तारीख और समय को capture करता है। दूसरी line,
Text_1.applyText(currentDate.toDateString());
toDateString() का उपयोग करके date को एक readable string format में convert करता है (उदाहरण के लिए: "Mon 27 Oct 2025") और फिर उसे Text_1 नामक text widget में प्रदर्शित करता है। यह तरीका dashboards, reports और interactive applications पर real-time stamp दिखाने के लिए उपयोगी है।
// Show message box
Application.showMessage(ApplicationMessageType.Error, "Incorrect Period!");
SAP Analytics Cloud (SAC) Analytic Application में user को एक error message display करता है। Application.showMessage() function एक सूचना display करता है, और ApplicationMessageType.Error specify करता है कि message एक error style (आमतौर पर एक चेतावनी icon के साथ red) में display होना चाहिए। " Incorrect Period"text प्रदर्शित सामग्री है, जो users को सूचित करती है कि उन्होंने एक invalid period चुनी है या दर्ज की है। यह users को गलतियों को सुधारने में मार्गदर्शन करने और गलत data actions को रोकने में मदद करता है। इसका उपयोग आमतौर पर filters, input submissions, या data refresh operations से पहले validation checks में clean और accurate analytics बनाए रखने के लिए किया जाता है।
// Export to Excel
ExporToExcel_demo.exportReport();
SAP Analytics Cloud (SAC) Analytic Application में किसी report या table को Excel file में export करने के लिए ExporToExcel_demo का उपयोग किया जाता है। यहाँ, ExporToExcel_demo, application में जोड़े गए किसी custom widget या Excel में Export component को refer करता है। जब exportReport()function को call किया जाता है, तो यह widget की built-in export action को trigger करता है, और link की गई table या data source के आधार पर automatic रूप से एक Excel (.xlsx) file generate करता है। यह users को SAC के बाहर data download और analyze करने की अनुमति देता है। इसे आमतौर पर एक button click event के पीछे रखा जाता है ताकि एक click से quick export संभव हो सके, जिससे उपयोगिता और reporting efficiency में सुधार हो सके।
// Get active page name
var PageName = Application.getActivePage();
console.log(PageName);
SAP Analytics Cloud (SAC) scripting में, Application.getActivePage() का उपयोग यह पहचानने के लिए किया जाता है कि story या analytic application का कौन सा page वर्तमान में screen पर active है। लौटाया गया value PageName variable में store होता है। यह तब उपयोगी होता है जब आपके application में कई pages हों, और आप users द्वारा देखी जा रही चीज़ों के आधार पर specific actions करना चाहते हों। अगली line, console.log(PageName);, active page का details browser console पर प्रदर्शित करती है, मुख्यतः debugging उद्देश्यों के लिए। यह developers को यह verify करने में मदद करता है कि वे सही page के साथ काम कर रहे हैं और development के दौरान script का परीक्षण करते समय behavior को track कर सकते हैं।
Words count on a page
You can run a small JavaScript in your browser’s console:
- Open your webpage where you want to count words.
- Press F12 → Console tab.
- Paste this code:
- Press Enter → It will print the word count of all visible text on your page.
let text = document.body.innerText;
let words = text.trim().split(/\s+/).length;
console.log("Word Count: " + words);
