Showing posts with label EPM. Show all posts
Showing posts with label EPM. Show all posts

Tuesday, July 28, 2020

Orphaned features in SharePoint Farm

Leave a Comment
While working for a client project and deploying existing SharePoint solution face issue about orphaned features which gives error a feature with feature id XXXXX already exist in farm.

There are two solution either in feature set force install option or delete orphaned features using following powershell commands:

Get-SPFeature | ? {$_.Scope -eq $null}


$feature = Get-SPFeature | ? {$_.DisplayName -eq "FeatureToBeDeleted"}

$feature.Delete()


Read More

Wednesday, August 7, 2019

SharePoint: How to verify current logged in user belong to which SharePoint Group

Leave a Comment
There was a scenario, we during our development cycle faced multiple time that we need to verify currently logged in user in SharePoint for its role or SharePoint Group. As based on role we have different business rules & business process automation. So following is server side code for verifying currently logged in user (either Active directory based or form based authtentication) belong to which SharePoint Group:

//Let user be authenticated first into SharePoint
SPClaimsUtility.AuthenticateFormsUser(
                       new Uri(SPContext.Current.Web.Url), username, password);                   
                       
                        SPUser spUser = SPContext.Current.Site.RootWeb.EnsureUser(SPContext.Current.Web.CurrentUser.LoginName);

                        //check logged in user belong to which SharePoint group/role
                        SPSecurity.RunWithElevatedPrivileges(delegate ()
                        {

                            //SPSite site = SPContext.Current.Site;
                            using (SPSite site = new SPSite(SPContext.Current.Web.Url))
                            {
                                using (SPWeb web = site.OpenWeb())
                                {                                   
                                    if(spUser!=null)
                                    {
                                        var userGroups = spUser.Groups;
                                        foreach (SPGroup group in userGroups)
                                        {
                                            if (group.Name.ToLower().Equals("role1"))
                                            {
                                                userGroup = "role1";
                                            }
                                            else if (group.Name.ToLower().Equals("role2"))
                                            {
                                                userGroup = "role2";
                                            }
                                            else if (group.Name.ToLower().Equals("role3"))
                                            {
                                                userGroup = "role3";
                                            }
                                        }
                                    }                                 
                                }
                            }
                        });
Read More

Saturday, November 24, 2018

PWA: EPM/Project Server site give administrator access to user or group for project web app

Leave a Comment
To give administrator access to user/group for project web app we need to run following powershell command
Grant-SPProjectAdministratorAccess -Url http://contoso-AppSrv/pwa -UserAccount contoso\john.woods
Read More

SharePoint 2013/2016: The local farm is not accessible. Cmdlets with FeatureDependencyId are not registered

Leave a Comment
While trying to give administrator access to user for an instance of PWA I tried to run following command in sharepoint powershell:
Grant-SPProjectAdministratorAccess -url XXXX user domain\XXXX

I came across following issues:

SharePoint 2013/2016: The local farm is not accessible. Cmdlets with FeatureDependencyId are not registered

Solution:
This happened b/c I tried to launch sharepoint powershell with user part of farm admin group, however I need to work with account similar access to sharepoint central admin app pool as that account requires right on server & databases to run configuration through powershell commands.
so I need to run following command throught account which I used to install my sharepoint farm:
Add-SPShellAdmin -UserName Domain\User



Read More

Wednesday, January 3, 2018

Disable or hide project server custom fields in project detail pages based on group current user belong too

Leave a Comment


Business Case:

Only PMO coordination team should able to update/set information related to project status. Currently project managers are updating project status which are affecting business validations & process flow.

Solution:
1.       Create a SharePoint group “PMO_Users”. Add PMO coordination team members to this group.
2.       Whenever a project is edited or created, at project details page, our custom module will verify if currently logged in user is part of “PMO_Users” group.
3.       If point (2) is true then project status button is enable and PMO coordination team can only able to update project status.
4.       Project managers can’t able to update project status (as they are not part of PMO_Users group.

Understanding:
This module works on the basis that project status (custom field) can’t be updated from Microsoft Project (client application) and only updateable from PWA.

Cross-Browser compatibility:
I have verified this module on chrome & internet explorer. 

Script/Code:

<script src="//code.jquery.com/jquery-1.10.2.js"></script>
<script>
ExecuteOrDelayUntilScriptLoaded(DisableProjectStatus,'sp.js');
function DisableProjectStatus()
{
var clientContext = new SP.ClientContext.get_current();
    var oWeb = clientContext.get_web();
    var currentUser = oWeb.get_currentUser();
    var allGroups = currentUser.get_groups();
    clientContext.load(allGroups);

    clientContext.executeQueryAsync(OnSuccess, OnFailure);

    function OnSuccess(sender, args)
    {
        var grpsEnumerator = allGroups.getEnumerator();
        var isNotPartOfPMO_Users=false;
        while(grpsEnumerator.moveNext())
        {          
            var group = grpsEnumerator.get_current();                  
            var grpTitle = group.get_title();
            if(grpTitle=='PMO_Users')
            {
                            isNotPartOfPCOAdmin=true;              
            }          
        }
        if(!isNotPartOfPMO_Users)
        {
            console.log('im not admin  user');
            var btnProjectStatus = $("button[id*='pfp_Repeater_ctl12_idCF_Btn_']");
            btnProjectStatus.attr("disabled", "disabled"); //similarly we can hide button as well.
        }
    }

    function OnFailure(sender, args)
    {
        console.log(args.get_message());
    }  
}
Read More

Tuesday, December 19, 2017

Project server: reserve keyword custom field odata feed

Leave a Comment
Issue: Odata error processing request:



We should not use reserve keyword while creating custom fields for project server (2010/2013/2016). What I faced while using Power BI through OData feed was facing conflict of my custom field with reserve keyword.
Cause: Duplicate custom field
There was a field called "Project ID" but this custom field internal name become "projectid" which is reserve internal field use by Project server for referencing different projects

Solution: 
Just rename custom field "Project ID" to "Internal Project ID" and it solve the issue.



 
Read More