Monday, April 13, 2015

How to setup a provider-hosted app for sharepoint 2013 running under local IIS

when we develop a provider-hosted app for sharepoint 2013 with visual studio 2013, we did not need to make any configuration on the sharepoint host site and configuration file in the project. we can simply click start button to debug the provider-hosted app project.

If the provider-hosted app is under specific application pool, in order to use the specific service account to access the database.


Step 1. we must configure the project to run under Local IIS.

Right click on the Web Project, the select Property from the Pop Menu to show the project property window as following.



Step 2. Register the App part for sharepoint in the development environment or farm, use the following link
http://<SharePointWebsite>/_layouts/15/AppRegNew.aspx.



right click on the AppManifest file, then select View Code to open the file in the visual studio, and get the client ID from the section AppPrincipal Section.

 <AppPrincipal>
    <RemoteWebApplication ClientId="da0b46be-1349-4429-a96c-e2410120b1c2" />
  </AppPrincipal>


App Domain: should be your  Full Computer Name in the System Windows.

Redirect URI: http://AppDomain/YourProviderHostedAppWeb/ 

then click on the Create button to register the App in the development environment.

please visit the Register by using AppRegNew.aspx section for detail explanation in the link below.

https://msdn.microsoft.com/en-us/library/office/jj687469.aspx

here is the summary of the succeed registration.



Now, we can press F5 to start the project and debug it. 

Warming: you must register the app again, if you close the project.

Tips: since the app is executed under specific application pool with credential being setup for the
service account. we must check the Show Processes from all users check box to show W3P.exe process












 







Thursday, April 9, 2015

use to dynamically increase array size in VBScript

when we need to break the comma separate string into an array in vbscript, we can call the split function in VBScript,


STKReq="110,112,113,114,115"
stockReqArray=Split(STKReq, ",")

if we have already define an array with fixed length, in case i have a array which has size 10. but we did not the numbers in the string. we can first split the numbers into an number array, then use ReDim Preserve to dynamically increase the existing array and preserve all existing value by coping them to the new array.

"The first ReDim creates a new array which replaces the existing array in variable intArray. ReDim copies all the elements from the existing array into the new array. It also adds 10 more columns to the end of every row in every layer and initializes the elements in these new columns to 0 (the default value of Integer, which is the element type of the array)."

you can get more detail information from this MSDN link

ReDim Statement (Visual Basic)


the snippet code demonstrates the new array had been created and copied the exciting the value to the new array, then initialize the newly added elements with blank value, since they are null by default.

 ReDim Preserve stockReqArray(10)
 for i=stockReqArraySize to 10
      stockReqArray(i)=""
  next