locked
Project server new resource Customization and Programming RRS feed

  • Question

  • hi

    how to set RBS value for a new resource programmatically in project server 2010?

    Sunday, May 18, 2014 4:45 PM

Answers

  • yes but along with that remember there is a checkout and checkin process as well so make sure you checkout the resource before performing the update and post update check back in the resource, something like below

    res.CheckOutResources(resGuid);
    res.UpdateResources(ds, false, true);
    res.CheckInResources(resGuid,false);


    Thanks | epmXperts | http://epmxperts.wordpress.com

    • Marked as answer by sheelaj Tuesday, May 20, 2014 5:52 PM
    Tuesday, May 20, 2014 1:06 PM
  • foreach (ResourceWebSvc.ResourceDataSet.ResourceCustomFieldsRow cfRow in resDs1.ResourceCustomFields)
                    {
                        //Match Guid for ECF not resource
                        if (cfRow.MD_PROP_ID == new Guid(ECFGuidForRBS))
                        {
                            //update the value
                            resDs1.ResourceCustomFields[0].CODE_VALUE = cfValueWOD;
                            resourceSvc.CheckOutResources(new Guid[1] { resid });
                            resourceSvc.UpdateResources(resDs1, true, true);
                        }
                    }

    Thanks | epmXperts | http://epmxperts.wordpress.com

    • Marked as answer by sheelaj Tuesday, May 20, 2014 5:52 PM
    Tuesday, May 20, 2014 5:33 PM
  • Thank u very much. I changed

    resourceSvc.UpdateResources(resDs1, false, true);

    after that it's working fine.
    • Marked as answer by sheelaj Tuesday, May 20, 2014 5:52 PM
    Tuesday, May 20, 2014 5:52 PM

All replies

  • It would be the same as you would do a ECF update refer to this excellent blog, instead of Task just call the specific resource dataset and update / create the RBS ECF

    http://blogs.msdn.com/b/brismith/archive/2010/08/25/project-server-adding-custom-fields-to-projects-and-tasks-using-the-psi.aspx


    Thanks | epmXperts | http://epmxperts.wordpress.com

    Monday, May 19, 2014 2:40 PM
  •   hi

    I created RBS ECF like this, 

     Guid cfIdWOD = new Guid("{000039B7-8BBE-4CEB-82C4-FA8C0C400284}");
     Guid cfValueWOD = new Guid("{CCDFA316-0E1B-4FFA-89F7-99869E239D0E}");
      //Resource uid
       Guid resid = new Guid("709233FB-0D78-4655-AF9B-43AC2BBC9C8A");

    //create a new row
    ResourceWebSvc.ResourceDataSet.ResourceCustomFieldsRow cfRowWOD = resDs1.ResourceCustomFields.NewResourceCustomFieldsRow();
      //Sets all values to NUll to begin
       cfRowWOD.SetDATE_VALUENull();
       cfRowWOD.SetTEXT_VALUENull();
       //General parameters
         cfRowWOD.MD_PROP_UID = cfIdWOD; //custom field ID
         cfRowWOD.CUSTOM_FIELD_UID = Guid.NewGuid();
         cfRowWOD.RES_UID = resid; //current project ID
           //add value
          cfRowWOD.FIELD_TYPE_ENUM = 21;
         cfRowWOD.CODE_VALUE = cfValueWOD; //test value
         //add the row to the data set
        resDs1.ResourceCustomFields.AddResourceCustomFieldsRow(cfRowWOD);

    it's not created in the new resource.I think i am missing some steps. Can u help

        
    Monday, May 19, 2014 6:23 PM
  • Guid cfIdWOD = new Guid("{000039B7-8BBE-4CEB-82C4-FA8C0C400284}");
     Guid cfValueWOD = new Guid("{CCDFA316-0E1B-4FFA-89F7-99869E239D0E}");

    Remove curly braces, it should be as below

    Guid cfIdWOD = new Guid("000039B7-8BBE-4CEB-82C4-FA8C0C400284");
     Guid cfValueWOD = new Guid("CCDFA316-0E1B-4FFA-89F7-99869E239D0E");

    Preview the dataset once you have added the row, it should show you the row added in the dataset


    Thanks | epmXperts | http://epmxperts.wordpress.com

    Monday, May 19, 2014 6:29 PM
  • I removed the curly braces. After that also RBS ECF is not created in the new resource. 

    Is it required to add this line( resourcewebsvc.updateresources(resDs1,true,true) ) or not. 

    Tuesday, May 20, 2014 9:45 AM
  • yes but along with that remember there is a checkout and checkin process as well so make sure you checkout the resource before performing the update and post update check back in the resource, something like below

    res.CheckOutResources(resGuid);
    res.UpdateResources(ds, false, true);
    res.CheckInResources(resGuid,false);


    Thanks | epmXperts | http://epmxperts.wordpress.com

    • Marked as answer by sheelaj Tuesday, May 20, 2014 5:52 PM
    Tuesday, May 20, 2014 1:06 PM
  • Thank u. It's working fine for the new RBS ECF value. To change the RBS ECF value( ie change the RBS ECF value from Project Manager to Team Leader) what are the steps I have to follow?. Can u help?

    Tuesday, May 20, 2014 4:19 PM
  • I am assuming you want to update the value within the RBS field, correct me if i am wrong..

    to update a value, loop within the resource dataset and fetch the custom field and simply update the lookup value GUID (By update i am assuming the row should be already there for the ECF, if not then create the row and assign value) followed by checkout >> update >> Checkin  


    Thanks | epmXperts | http://epmxperts.wordpress.com

    Tuesday, May 20, 2014 4:23 PM
  • 
               Guid cfValueWOD = new Guid("28CAF8A3-477A-42E2-B8F9-DFDFE102313B");
                    //Resource uid
                    Guid resid = new Guid("962E4495-4985-49FF-AF67-520884604624");
                    ResourceWebSvc.ResourceDataSet resDs1 = new ResourceWebSvc.ResourceDataSet();
                   resDs1 = resourceSvc.ReadResource(resourceUid);
                    //iterate over fields and update them to the table for WO Status
                    foreach (ResourceWebSvc.ResourceDataSet.ResourceCustomFieldsRow cfRow in resDs1.ResourceCustomFields)
                    {
                        //if field exists update it
                        if (cfRow.RES_UID == resid)
                        {
                            //update the value
                            resDs1.ResourceCustomFields[0].CODE_VALUE = cfValueWOD;
                            resourceSvc.CheckOutResources(new Guid[1] { resid });
                            resourceSvc.UpdateResources(resDs1, true, true);
                        }
                    }
    Is it correct for edit particular RBS ECF value?
    Tuesday, May 20, 2014 5:21 PM
  • foreach (ResourceWebSvc.ResourceDataSet.ResourceCustomFieldsRow cfRow in resDs1.ResourceCustomFields)
                    {
                        //Match Guid for ECF not resource
                        if (cfRow.MD_PROP_ID == new Guid(ECFGuidForRBS))
                        {
                            //update the value
                            resDs1.ResourceCustomFields[0].CODE_VALUE = cfValueWOD;
                            resourceSvc.CheckOutResources(new Guid[1] { resid });
                            resourceSvc.UpdateResources(resDs1, true, true);
                        }
                    }

    Thanks | epmXperts | http://epmxperts.wordpress.com

    • Marked as answer by sheelaj Tuesday, May 20, 2014 5:52 PM
    Tuesday, May 20, 2014 5:33 PM
  • Thank u very much. I changed

    resourceSvc.UpdateResources(resDs1, false, true);

    after that it's working fine.
    • Marked as answer by sheelaj Tuesday, May 20, 2014 5:52 PM
    Tuesday, May 20, 2014 5:52 PM