Saturday, September 13, 2014

SharePoint : Create list items in external list using SharePoint Workflow

שלום חברים,

במאמרים הקודמים שפרסמתי הצגתי פתרון לקישור בין Oracle ל-SharePoint בעזרת שירות BCS (מאמר : SharePoint : Connect to Oracle Using WCF via BCS) ולאחר מכן הקמת External Content Type שאמון על מיפוי הנתונים ל-SP (מאמר: SharePoint : Connecting to WCF Service as ExternalContent Type).

אחרי שראינו שהכל עובד Perfect וניתן לסנכרן נתונים באופן דו-כיווני ל-SP ול-Oracle התברר שהלקוח רוצה לייצר טפסים דינמיים עם שדות מורכבים בעזרת InfoPath, מה שלא מתאפשר ביצירת External List מ-External Content Type. היינו בישורת האחרונה לפרויקט והתחלנו לחשוב על פתרון יצירתי שייתן מענה הולם לבעיה ושאינו דורש פיתוח.. אז .. שימוש ב- SharePoint Workflows נראה לי הפתרון הכי נכון לבעיה שלנו.

התחלנו ביצירת רשימת SharePoint (Custom List) שמורכבת משדות מורכבים כמו People Picker, שדה אפשרויות כ-Dropdown ועוד.

לאחר מכן פתחנו את הרשימה כטופס ב-InfoPath (לחיצה על פקד Customize Form ב-Ribbon) עיצבנו את הטופס כמו שאנחנו רוצים, שמרונו והעלנו אותו ל-SP.

לאחר מכן יצרנו Workflow  דרך SharePoint Designer :

.1 פתחו את SharePoint Designer והתחבר לאתר שלך.

.2 לחצו על "זרימות עבודה" בתפריט הצדדי



.3 צרו זרימת עבודה מסוג "רשימת זרימת עבודה" , בחרו "רשימת זרימת עבודה" מה-Ribbon ובחרו את הרשימה שזרימת עבודה תהיה מקושרת אליה.



.4 תנו שם ותיאור לזרימת העבודה ולאחר מכן לחצו על אישור.



.5 לחצו בתוך "שלב 1" ולחצו על הלחצן "הפעולה" בRibbon. בחרו "צור פריט רשימה"



.6 פעולת זרימת עבודה חדשה נוצרה בתוך "שלב 1". לחצו על "רשימה זו" ובחרו את הרשימה החיצונית כדי ליצור הפריט החדש בה.



.7 כאשר תיבת הדו-שיח נפתחת, בחרו את הרשימה החיצונית. לחצו על לחצן "הוסף ..." ומפה את השדות מהרשימה החיצונית למאפייני ומשתני זרימת העבודה.



.8 לחצו על אישור כאשר תסיימו. שלב 1 בזרימת העבודה צריך להיראות כמו בתמונה למטה



.9 אפשר להוסיף עוד פעולות לזרימת עבודה ולאחר מכן לשמור ולפרסם אותו לרשימה.



לאחר שיצרתם את ה-Workflow חשוב לוודא של-User שמריץ את ה-Application Pool תחתיו רץ האתר יש הרשאות לגשת ל-Oracle Database , הרשאה זו ניתנת דרך שירות ה-Secure Store.
בדר"כ האפליקציה נוצרת אוטומטית ב-Secure Store אבל אם אינכם ו=רואים את האפליקציה ניתן ליצור אחת כזו :
1.       כנסו לניהול המרכזי של -SP
2.       לחצו על ניהול יישומים ולאחר מכן נהל את יישומי שירות

3.       אנו מעוניינים בשירות הSecure Store  ולכן אנחנו לוחצים עליו
4.       ניצור אחד חדש ... לחצו על חדשים

5.       אנו יוצרים מזהה יישום יעד, שם לתצוגה שיכולה להיות אותו הדבר כמו ה- App ID, וכן הלאה.



6.       בחרו  באפשרות "קבוצה" כסוג יישום יעד שלי.
7.       השאירו את השדות כפי שהם ללא שינוי.


8.       הזינו את שם המשתמש  שמריץ את ה-Application Pool בשני השדות.


9.       לחצו OK וסיימו את התהליך.


לאחר מכן יש לשנות את ההגדרות חיבור שיצרנו ב-SharePoint Designer כך :

1.       עברו לSharePoint Designer  והתחברו לאתר שלכם. בחרו אובייקט אתר סוגי תוכן החיצוני ופתחו את סוג התוכן החיצוני שלכם. לחצו על "מאפייני חיבור ערוך" ב-Ribbon:


2.       במאפייני Endpoint, יש לשנות את מצב האימות להיות אחת מהאפשרויות. בחרו את הרמה-אישית המתאימה ליישום שלכם. הגדיר
ו את ה-Secure Store להיות זיהוי של היישומים שיצרנו לעיל.




3.       במאפייני מידע, שנו את מצב האימות להיות אחת מהאפשרויות. הגדר את החנות המאובטחת יישומי זיהוי להיות זיהוי של היישומים שיצרנו לעיל.


4.       לחצו על אישור

חזרו לרשימת SharePoint שלכם שמשויכת לזרימת עבודה. צרו פריט חדש והפעילו את זרימת העבודה באופן ידני. כאשר פעולת יצירת פריט מבוצעת, כנסו לרשימה החיצונית יוצג פריט חדש.

בהצלחה !
רון נס.


========================================================================================================================================================================================================================================







Hello friends,

In my previous articles I've posted about the linkage between Oracle to SharePoint using BCS Service (Article: SharePoint: Connect to Oracle via WCF Using BCS), and then the establishment of External Content Type mapping data to SP (Article: SharePoint: Connecting to WCF Service as External Content Type).

After seeing that everything works perfect and can synchronize data with two-way SP and Oracle I found out the customer wants to create dynamic forms with InfoPath Forms and that the Form Contain complex fields, which is not possible in External List. We were in the final stretch to the project and we started thinking about a creative solution will meet the problem and does not require developing... So... Using SharePoint workflows seems most correct solution to our problem.

We started creating SharePoint list (Custom List) consists of complex fields like People Picker field as Dropdown options and more.

Then we opened the list as a form in InfoPath (clicking on the Customize Control Form in Ribbon) designed the form as we want, save it and publish the form to SP.

Then we created a Workflow using SharePoint Designer:

1.     Open the SharePoint Designer and connect to your site.

2.     Click on "workflows" on the side menu


3.     Create a "List Workflow", select "List Workflow" Ribbon and select from the list workflow will be linked to it.


4.     Name the workflow description, and then click OK.


5.      Click in "Step 1" and press "action" in the Ribbon. Select "Create list item"


6.     Operation of a new workflow created in "Step 1". Click the "this list" and select the external list to create a new item in it.


7.     When the dialog box opens, select the external list. Press the "Add ..." and map the fields from the list the characteristics and variables outside the workflow.


8.     Click OK when you are done. Step 1 in the workflow should look like the image below


9.     You can add more workflow steps and then save and publish it to the list.


Once you have created the workflow is important to ensure that the User Application Pool has permissions to access Oracle Database, authorization is granted through the Secure Store Service.

Usually the application is automatically created in Secure Store but if don't you can create one:

1.     Enter SharePoint Central Admin  
2.     Click Manage Applications and then Manage Service Applications

3.     We are interested in the Secure Store Service so we click on
4.     create a new one ... click New

5.     We create a target application ID, display name can be the same as the App ID, and so on.



6.     Select "Group" My target application type.
7.      Leave the fields as they are the same.

8.     Enter the name of the user running the Application Pool in both fields.

9.      Click OK and finish the process.


Then change the connection settings created in SharePoint Designer as follows:

1.     Go to SharePoint Designer and connect to your website. Select external content types and open the type of your external content. Click on "Edit Connection Properties" in Ribbon

2.     Endpoint properties, change the authentication mode to be an option. Select the appropriate interpersonal level for your application. Set to the Secure Store Application ID created above.

3.     Characteristics of the information, change the authentication mode to be an option. Set the secure store application ID identifying applications to be created above.

4.      Click OK

Back to your SharePoint workflow associated. Create a new item and run the workflow manually. When item creation operation is performed, go to the external list,  a new item is shown there.

Good Luck J
Ron Ness.