Wednesday, May 15, 2019

Move/Copy document or item from one site collection to other site collection



Enable workflow elevated permissions

Below are the high-level steps to do enable the workflow:

  1. Allow the workflow to use app permissions in a SharePoint Server 2013/Online site.
  2. Grant full control permission to the workflow.
  3. Wrap the call action inside app step.

  • Go to Site Settings, under Users and Permissions, and click Site app permissions.   
  • Activate the Workflows can use app permissions feature 

Refrence:
https://docs.microsoft.com/en-us/sharepoint/dev/general-development/create-a-workflow-with-elevated-permissions-by-using-the-sharepoint-workflo

Save Pen Input , Images into SharePoint using Power Apps and Flows

Save Pen input or Image into SharePoint using power apps and flows

1. Create flow

New --> Create from template -- > select upload a photos to SharePoint folder

            get  file name and file content from power apps button trigger:

            get and set file Name:

              Add action -- > Data Operation(composed)

              triggerBody()['file']['name']
           
            get and set file content:

            Add action -- > Data Operation(composed)

            base64ToBinary(triggerBody()['file']['contentBytes']) 


          Create file:
                         
            Site address:  siteUrl
            Library:         pictureLibarry
            File:               test.jpg
            ContetBytes:

Save flow

2.power app button trigger switch to flow (pass file from power apps to flow)

open the Url: https://flowstudio.app/

open the above link and right click on file display of the flow and change the JSON definition of the trigger.manual.kind from "Button" to "PowerApp".

3.create a power app screen which contains text input, pen input and button controls

add below code button onSelect

Patch(PowerAppsImages, Defaults(PowerAppsImages), {Title: txtTitle.Text, MyImageData: PenSignature.Image });

PowerAppsFlowUploadImage.Run({file:{name:"Test.jpg",contentBytes:PenSignature.Image}});

Patch command save metadata into sharepoint list (PowerAppsImages) and file pass to flow
flow read the file and save into library and metadata into list.

Below link for reference:
http://johnliu.net/blog/2018/7/the-simplest-no-code-solution-to-save-pictures-files-from-powerapps-to-flow

Friday, January 5, 2018

Tuesday, October 17, 2017

Array values are changes in Angular JS

Array values are changes when we are assigning the scope array values.
Solution : angular.Copy

EX:

for (var i = 0; i < $scope.teamMembers.length; i++) {
   var newTeamMember = angular.copy($scope.teamMember[i]);
  
    $scope.team.teamMembers.push(newTeamMember);
}

 

Monday, September 25, 2017

Queue in Angular JS



var apiList = ["venkat", "vashith", "nagesh", "utejj"];
var requestUrl = "users/add" + window.location.search;
function AddUsers() {
    return $q.all(apiList.map(function (item) {
        return $http({
            method: 'POST',
            url: requestUrl / item
            //,data: item     //we have internal collection use data
        });
    }))
    .then(function (results) {
        var resultObj = {};
        results.forEach(function (val, i) {
            resultObj[apiList[i]] = val.data;
        });
        return resultObj;
    });
}

Sunday, February 5, 2017

Based on the culture name load the resource files


Add file to project with name : App_GlobalResources
Create resource files in above folder like as following :
enUS.resx
esEs.resx
--
--ect
write the below code in test.aspx.cs:
-----------------------------------------
  protected void Page_PreInit(object sender, EventArgs e)
        {          
            try
            {
                string SPLanguage = Request.QueryString["SPLanguage"];
                string[] arrSPLanguageSplit = SPLanguage.Split('-');
                if (arrSPLanguageSplit.Length > 0)
                {
                    string languageNameAfterSplit = arrSPLanguageSplit[0] + arrSPLanguageSplit[1];
                    if (File.Exists(MapPath(@"~\App_GlobalResources\" + languageNameAfterSplit + ".resx")) == true)
                    {
                        HttpContext.Current.Session["resourceFileName"] = languageNameAfterSplit;
                    }
                    else {
                        HttpContext.Current.Session["resourceFileName"] = "enUS";                  
                    }                
                }
                else {
                    HttpContext.Current.Session["resourceFileName"] = "enUS";              
                }
            }
            catch (Exception ex)
            {  
   HttpContext.Current.Session["resourceFileName"] = "enUS";
                EventLog.WriteEntry("Page_PreInit:resourceFileName", ex.Message, EventLogEntryType.Information);
                     
            }
         }

write the below code in test.aspx:
--------------------------------------
<script language="javascript" type="text/javascript">
 $(document).ready(function ()
{
  var TargetSite = '<%= HttpContext.GetGlobalResourceObject(HttpContext.Current.Session["resourceFileName"].ToString(), "TargetSite") %>';
  var TargetLibrary = '<%= HttpContext.GetGlobalResourceObject(HttpContext.Current.Session["resourceFileName"].ToString(), "TargetLibrary") %>';  
         
            $('#lblTargetSite').text(TargetSite);
            $('#lblTargetLibrary').text(TargetLibrary);
});
</script>

UI:
----
    <div>
         <label id="lblTargetSite" runat="server"></label>        
        </div>
        <br />
        <div >
           <label id="lblTargetLibrary" runat="server"></label>    
        </div>

Thursday, December 8, 2016

Provider Hosted Apps in SharePoint 2013


Create Certificate (Cer):
Go to IIS
Click on server certificates
Next click on the right pane select the self-signed certificate and give the name: TrustedCertificate then
Click on OK
Export Certificate (pfx):
In IIS Click on the certificate next click on the export then select location and give password
Copy Certificate (Cer):
In IIS double click the certificate next select details tab click on CopytoFile
Next click on next button select the No do not export the private key
Next click on next button select the DER encoded binary
Next click on next button choose the file where you want save
Next click on finish button
Run the below PowerShell command:
$cert=Get-PfxCertificate -FilePath "C:\Certs\TrustedCertificate.cer"
 $issuerid=[System.Guid]::NewGuid().ToString() // 35f57afc-2895-4825-9c60-bc37a91e2a51
 $realmid=Get-SPAuthenticationRealm -ServiceContext "http://SPSite:41127/sites/DeveloperSite/"
 //7d99f2ba-4f1e-4962-8a71-174f8df35404
$registeredName=$issuerid + "@" + $realmid
New-SPTrustedSecurityTokenIssuer -Name "DevelopmentApp" -RegisteredIssuerName $registeredName -IsTrustBroker -Certificate $cert
Note:
$issuerId will give the Issuer id
$realmid will give the real Id
$registeredName will give the registered name.
Go to Visual studio:
Select the App for SharePoint the app name: PagesCreationUsingPageViewerWebpart click on OK.
Next give developer site URL and select provider hosted
Click on next select the ASP.NET web forms Application
Click on next select use certificate and give the below details: pfx certificate location, password and realmid
Check in Web.config is done properly or not.
Step 9:Run the project in visual studio and check whether client Id is generated or not in web.config.
Step 10:Change the Permission in AppManifest.xml
Step 12:Run the below script  for generating APP ID
$clientid = " bded8c2e-da2d-4c2a-a8c3-0dbcf3e42f8e"
 $appId = $clientid + "@" + $realmid
 Register-SPAppPrincipal -Site "http://SPSite:41127/sites/DeveloperSite/"  -NameIdentifier $appId
 
Step 13:Run the below script
$config = (Get-SPSecurityTokenServiceConfig)
$config.AllowOAuthOverHttp = $true
$config.Update()
 
Step 14 : Deploy it finally.