Posts

React Native: buffer is not defined

Image
I tried to use "azure-mobile-apps-client" npm package in a React Native app, and it throws error "buffer is not defined" in Simulator. I searched around in google.com, and found out below solution: global.Buffer = global.Buffer || require('buffer').Buffer; var WindowsAzure=require('azure-mobile-apps-client'); I added above code to the .js file, and run it again. Done! the issue is gone and I can get the Azure Mobile App Service Client object which can be seen in the debug code in Chrome.     Run "npm i", and then run the app successfully. :) Further Study     I had been studied the online course " The Complete React Native and Redux Course ", it gave me the clear explanation and instruction with step by step procedures to learn the core knowledge to build React components for mobile devices. It's suitable for all levels. The course has sample code and completed projects in gitHub.com. Instructor : St...

Chatbot - enhance SharePoint, Office365 (Digital Workplace) & Customer Engagement

Have you noticed the AI technology especially Microsoft Cognitive Services have been used in the workplace and marketing area recently? One feature AI product is chatbot (Digital Assistant) – business organizations are increasingly developing bots to handle various business processes including routine HR tasks, customer service, insurance claim handling, sales, marketing and so on. Have you experiencing that find information from a long content web page or document in SharPoint site, or try to find the tiny search box on the corner of the Home page to search site contents? Now chatbot can make you work easier, you can type in or speak question and get an answer retrieve from a SharePoint FAQ List or page directly from Sky Business or Cortana. A typical use case is a 24*7 IT help desk, e.g. employee can ask their current reporting manager retrieves from HR Chris system, or their travel expense claim feedback. Or you can search the documents of document library directl...

React Native error - Cannot find module 'metro-react-native-babel-preset'

Image
I created a React native app using "react-native init <App Name> " but received below error when try to run it in Simulator: Cannot find module 'metro-react-native-babel-preset' I resolved the error by adding below line under "dependencies" in package.json.     "@babel/runtime": "^7.0.0-beta.55"  Run "npm i", and then run the app successfully. :) Further Study     I had been studied the online course " The Complete React Native and Redux Course ", it gave me the clear explanation and instruction with step by step procedures to learn the core knowledge to build React components for mobile devices. It's suitable for all levels. The course has sample code and completed projects in gitHub.com. Instructor : Stephen Grider -  Engineering Architect, Stephen Grider has been building complex Javascript front ends for top corporations in the San Francisco Bay Area.

Javascript - Equivalent of .NET DateTime.MaxValue.Ticks

According to article "Azure Storage Table Design Guide: Designing Scalable and Performant Tables" " https://docs.microsoft.com/en-us/azure/cosmos-db/table-storage-design-guide#log-tail-pattern ". The below code is used to store the entities using a RowKey that naturally sorts in reverse date/time order by using so the most recent entry is always the first one in the table. string invertedTicks = string.Format("{0:D19}", DateTime.MaxValue.Ticks - DateTime.UtcNow.Ticks); The Equivalent JavaScript code is as below: var currentTimeInMilliseconds=moment().add(-2, 'hours').valueOf() * 10000 + 621355968000000000; //MaxTime is the DateTime.MaxValue.Ticks var MaxTime = 3155378975999999999; var rowKey =(MaxTime - currentTimeInMilliseconds).toString();

Javascript - Handing XML document with prefix and name space

If you need to process XML string with  namespace such as  "<book xmlns:xi='http://www.w3.org/2001/XInclude'>     <Name>Some text</Name>     <Price>$12</Price> </book>"  , then you can use " getElementsByTagNameNS " function to process it. Its formula is:   elements = element.getElementsByTagNameNS(namespaceURI, localName) Below code is th example of using   " getElementsByTagNameNS " function and explore XML child nodes  in JavaScript. var z=xmlDocument. getElementsByTagNameNS(' http:/ /schemas.microsoft.com/ado/ 2007/08/dataservices ', 'Rows'); x=z[0].firstElementChild.childNodes; for (i = 0; i < x.length ;i++)  {      console.log(x[i].firstChild);       if (x[i].firstChild.innerHTML=="URL")        {                    console.log(x[i].children[1]. innerHTML);   ...

Handle "Forgot your password" / "Reset password" in Azure B2C Activity Directory "SignInSignUp" policy

Image
When you use Azure B2C Activity Directory "SignInSignUp" policy in your application, then you will see below screen shot signin /signup pop up window. If you click on "Forgot your password?", and the login is failure at this code " await PublicClientApp.AcquireTokenAsync(Scopes, GetUserByPolicy(PublicClientApp.Users, PolicySignUpSignIn), UIBehavior.SelectAccount, string.Empty, null, Authority) ;". You can catch this error and the error message should contains "AADB2C90118", and then you can handle this error to invoke "Reset Password Service" with following code:  AuthenticationResult authResult= await PublicClientApp.AcquireTokenAsync(Scopes, GetUserByPolicy(PublicClientApp.Users, PolicySignUpSignIn), UIBehavior.SelectAccount, string.Empty, null, AuthorityResetPassword);    You can retrieve user name and "id_token" from "authResult" from above code. Refer to Azure B2C sample project " https://github.com...