Sue Hernandez's SharePoint Blog

SharePoint and Related Stuff

Category Archives: Uncategorized

What happened to my ULS Logs? Why is the Tracing service disabled?

I was happily developing and testing, and came across an error.  No big deal, I’ll just grab the Correlation ID and take a peek in the ULS logs, right?  But when I went to where they were stored – there were NO logs.

First I went to Central Admin –> Monitoring –> Configure Diagnostic logging.

  • I checked to ensure the path was correct
  • I reset all categories to default logging level
  • I even tried to change the log location, then change it back.

Nothing.

Then I noticed that in the “Services” mmc plugin, the service “SharePoint Tracing Service” (SPTraceV4) was not only stopped but disabled!

Well OK, so I enabled it and started it.   And got my logs just fine!!!  ………for about an hour, after which it just disabled itself again.  Sigh.

Found the answer on StackExchange (link below) – the “default state” of the service was set to Disabled, so the Health Analyzer keeps shutting it back off.  So the fix is to change its default state to back on.

$services = (Get-SPFarm).Services | Where Name -match "SPTraceV4"
$instances = @($services.Instances)

foreach($instance in $instances) {
     $id = $instance.ID | Select -ExpandProperty Guid

     Start-SPServiceInstance -Identity $id
}

References

https://sharepoint.stackexchange.com/questions/62897/sptracev4-being-disabled

~ Sue

Advertisements

Error occurred in deployment step ‘Add Solution’: Error: Cannot add the specified assembly to the global assembly cache

Hello Again!

It’s been a while!!  Things have been hectic.  I am now employed at a new job, doing more SharePoint-ie things!!  And thankfully, learning, learning, learning!!

Error Message:

Came across this error today:
“Error occurred in deployment step ‘Add Solution’: Error: Cannot add the specified assembly to the global assembly cache: MyProjectOutput.dll.”

Thanks to a few helpful blog and forum posts, the answer was this:

  1. Either retract solution from Visual Studio, and/or manually remove .dll from the GAC (C:\Windows\assembly)
  2. Close Visual Studio
  3. [Not sure if this is needed] Restart SharePoint Timer Service (SPTimerV4)

Also try these troubleshooting steps:

  • Recycle Application Pool or do an IIS Reset (could also add this as a Pre-Deployment step: Project Settings/SharePoint tab)
  • Put the dll in question into its own solution and deploy that once.  Leave your changes for your main project package.
  • Ensure that if you have multiple projects that reference that DLL (such as a Helper or Utilities class), that you are using the correct reference.  Possibly remove the project reference, and re-add.
  • Check to ensure that any FeatureActivating code is not busting something

Thanks to these references:

 

I hope to keep up the blogging now that things are cooling down!!
~ Sue

InfoPath book started

I have decided to start writing an InfoPath book that I intend to self-publish (most likely). If you have anything specifically you’d be interested in seeing, please let me know in the comments.

It’s been a while, my friends…

Hi everyone!

I’m still happily a SharePoint 2013 developer. I still work with InfoPath. I haven’t blogged in forever.

I am shortly returning to the blogging world. I will blog on PowerShell and JSLink.

Thanks for sticking around!

 

[On a personal note, also check out my new blog – I’m writing a book. From Zero to Hero – Journey of a Novelist

Silverlight Gantt Part 6

At long last I’m getting back to my posts with the Silverlight Gantt Chart.  I had a request to post the source code, and if I can clean it properly, I will do so – probably in my next (final) post.

Getting the X Axis to have a dynamic interval such that it only shows about 6 -7 points at a time

By default, it shows so many points on the X axis that your points either run into each other or get put on 2 lines.  So this is a way to control how many points get shown.

This one’s easy – you just need to calculate a numerical value and set the interval in code.  I’m sure my math isn’t perfect, but this was my quick n dirty way to calculate and then set the interval .

// Set the Interval so we don’t get 2 rows of labels, which 
// seems to be the default
int maxNumOfLabelValues = 4;
int interval = 1;

if(max > 10000)
{
     interval = Convert.ToInt32((Math.Round((max / 10000)) * 10000) / maxNumOfLabelValues);
}
elseif(max > 1000)
{
     interval = Convert.ToInt32((Math.Round((max / 1000)) * 1000) / maxNumOfLabelValues);
}
elseif(max > 100)
{
     interval = Convert.ToInt32((Math.Round((max / 100)) * 100) / maxNumOfLabelValues);
}
elseif(max > 10)
{
     interval = Convert.ToInt32((Math.Round((max / 10)) * 10) / maxNumOfLabelValues);
}

// Set the axis data
((LinearAxis)(((BarSeries)(mcChart.Series[0])).DependentRangeAxis)).Minimum = 0;
((LinearAxis)(((BarSeries)(mcChart.Series[0])).DependentRangeAxis)).Maximum = max + (max * .1);
((LinearAxis)(((BarSeries)(mcChart.Series[0])).DependentRangeAxis)).Interval = interval;

 Getting the X Axis to Rotate

I wanted to show the X Axis point labels in such a way that they didn’t overlap on top of one another.  So we apply a transform to the XAML to rotate the labels by a negative 60 degrees.

<!– X Axis –>
<Style x:Key=”HorizontalAxisStyle” TargetType=”chartingToolkit:AxisLabel”>
     <Setter Property=”Margin” Value=”0,5,0,0″/>
     <Setter Property=”Template”>
          <Setter.Value>
               <ControlTemplate TargetType=”chartingToolkit:AxisLabel”>
                    <layout:LayoutTransformer>
                         <layout:LayoutTransformer.LayoutTransform>
                              <RotateTransform Angle=”-60″ />
                         </layout:LayoutTransformer.LayoutTransform>
                         <TextBlock Padding=”0″ DataContext=”{Binding}”
                              Text
=”{Binding Converter={StaticResource AxisDateFormatConverter}, ConverterParameter={StaticResource axisMinDate}}” />
                    </layout:LayoutTransformer>
               </ControlTemplate>
          </Setter.Value>
     </Setter>
</Style>

 Getting “Extra Stuff” inside the Y Axis Label area

I wanted to put some “extra” items inside the Y axis label – not just the label of the data point, but also some extra information about that data point.  So for example I wanted to put a glassy ball-dot kind of thing, representing the “health” of the project, as well as putting the project name, as well as putting some blurb about the status of the project.

The first thing I had to do was to create a Data Item Object (did I show you this object in an earlier post?) and then a custom class for the Gantt Y Axis object.

using System;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;

namespace SilverlightGantt
{
     public class DataItem
        {
          public string Key { get; set; }
          public DateTime MinDate { get; set; }
          public double StartDate { get; set; }
          publicd ouble EndDate { get; set; }
          public string TextLabelMargin { get; set; }
          public string Foreground { get; set; }
          
public string DotBackground { get; set; }
          public string LabelText { get; set; }
          public string ExtraStuffVisibility { get; set}

          public DateTime StartDateDate { get; set; }
          public DateTime EndDateDate { get; set; }

          public string FormattedValue
          {
               get
                         {
                                   return string.Format(“{0:MM/dd/yyyy}”, EndDateDate);
              
}
                }

               public void SetDateDoubles()
         
{
                        if (MinDate != DateTime.MinValue)
              
{
                                 StartDate = (StartDateDate.Subtract(MinDate)).Days;
                                 EndDate = (EndDateDate.Subtract(MinDate)).Days;
                        }
               }

        public DataItem(string _key, DateTime _start, DateTime _end, string _margin, string _foreground)
        
{
                      Key = _key;
                      StartDateDate = _start;
                      EndDateDate = _end;
                      Foreground = _foreground;
             }

        public DataItem()
       
{
             }
       }
}

using System;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Controls.DataVisualization;
using System.Windows.Controls.DataVisualization.Charting;

namespace SilverlightGantt
{
     [StyleTypedProperty(Property = “AxisLabelStyle”, StyleTargetType = typeof(AxisLabel))]

     public class GanttYAxisCategoryAxis
        {
          public GanttYAxis()
                {
                }

          protected
overridevoid PrepareAxisLabel(Control label, object dataContext)
                {
               object newCTX = null;

               object ctx = this.DataContext;
               DataItem[] allItems = ctx as DataItem[];
               if (allItems != null)

                        {
                   foreach (DataItem item in allItems)

                               {
                                       if(dataContext.ToString() == item.Key)
                                       {
                                                 newCTX = item;
                             break;
                                      }
                              }
                      }

             base.PrepareAxisLabel(label, newCTX);
               }
       }
}

So the next thing I had to do was to put everything in the Control Template for the Y Axis that I wanted to see, and then add binding to be able to fill in that information.

<!– Y Axis –>
<Style x:Key=”VerticalAxisStyle” TargetType=”chartingToolkit:AxisLabel”>
     <Setter Property=”Margin” Value=”0,0,5,0″/>
     <Setter Property=”HorizontalAlignment” Value=”Left” />
     <Setter Property=”Template”>
          <Setter.Value>
               <ControlTemplate TargetType=”chartingToolkit:AxisLabel”>
                    <StackPanel x:Name=”xAxisStackPanel” MinHeight=”37″ Orientation=”Horizontal” HorizontalAlignment=”Left” Margin=”0,0,5,0″>
                         <!– Project Name : Key –>
                         <TextBlock Visibility=”{Binding ExtraStuffVisibility}” Text=”{Binding Key}” TextWrapping=”Wrap” Width=”75″ 
                              HorizontalAlignment
=”Left” VerticalAlignment=”Center” />
                         <!– Glassy Dot : DotBackground –>
                         <Grid Margin=”5,0,0,0″ Visibility=”{Binding ExtraStuffVisibility}”>
                              <Ellipse Fill=”{Binding DotBackground}” HorizontalAlignment=”Left” Stroke=”Black” Width=”25″ Height=”25″/>
                              <Ellipse HorizontalAlignment=”Left” StrokeThickness=”1″ Stroke=”{Binding DotBackground}” Width=”25″ Height=”25″ Opacity=”0.5″>
                                   <Ellipse.Fill>
                                        <LinearGradientBrush EndPoint=”0.5,1″ StartPoint=”0.5,0″>
                                             <GradientStop Color=”#3FFFFFFF”/>
                                             <GradientStop Color=”#00787878″ Offset=”0.5″/>
                                             <GradientStop Color=”#99000000″ Offset=”1″/>
                                        </LinearGradientBrush>
                                   </Ellipse.Fill>
                              </Ellipse>
                              <Ellipse HorizontalAlignment=”Left” StrokeThickness=”0″ Stroke=”{Binding DotBackground}” Width=”25″ Height=”25″>
                                   <Ellipse.Fill>
                                        <RadialGradientBrush>
                                             <GradientStop Color=”#99000000″ Offset=”1″/>
                                             <GradientStop Color=”#66FFFFFF”/>
                                        </RadialGradientBrush>
                                   </Ellipse.Fill>
                              </Ellipse>
                              <Ellipse HorizontalAlignment=”Left” Margin=”5,2,0,0″ VerticalAlignment=”Top” Width=”15″ Height=”15″>
                                   <Ellipse.Fill>
                                        <LinearGradientBrush EndPoint=”0.5,1″ StartPoint=”0.5,0″>
                                             <GradientStop Color=”Transparent” Offset=”1″/>
                                             <GradientStop Color=”#BAFFFFFF”/>
                                        </LinearGradientBrush>
                                   </Ellipse.Fill>
                              </Ellipse>
                         </Grid>
                         <!– Status Message : LabelText –>
                         <TextBlock Margin=”5,0,0,0″ Visibility=”{Binding ExtraStuffVisibility}” TextWrapping=”Wrap” Text=”{Binding LabelText}”
                              Width
=”100″ Height=”Auto”HorizontalAlignment=”Left” VerticalAlignment=”Center” />
                    </StackPanel>
               </ControlTemplate>
          </Setter.Value>
     </Setter>
</Style>

Then I needed to update my Grid XAML to reference the custom Gantt Y Axis object:

<Grid x:Name=”LayoutRoot” Background=”White”>
     <me:GanttChart x:Name=”mcChart” Margin=”0″ BorderBrush=”Transparent” Height=”400″ Width=”500″
          Style=”{StaticResource ChartStyle1}”>
          <chartingToolkit:Chart.Series>
               <me:GanttBarSeries x:Name=”BarSeries1″ DataPointStyle=”{StaticResource BarTemplateStyle1}”>
                    <chartingToolkit:BarSeries.DependentRangeAxis>
                         <chartingToolkit:LinearAxis Orientation=”X” AxisLabelStyle=”{StaticResource HorizontalAxisStyle}” />
                    </chartingToolkit:BarSeries.DependentRangeAxis>
                    <chartingToolkit:BarSeries.IndependentAxis>
                         <me:GanttYAxis x:Name=”customYAxis” Orientation=”Y” AxisLabelStyle=”{StaticResource VerticalAxisStyle}” />
                    </chartingToolkit:BarSeries.IndependentAxis>
               </me:GanttBarSeries>
          </chartingToolkit:Chart.Series>
     </me:GanttChart>
</Grid>

And finally I needed to set the Data Context for the GanttYAxis to the data points in the MainPage.xaml.cs codebehind where I’m setting everything up.

// Points show from bottom to top, so reverse it to show “1” at the top
dataPoints.Reverse();
((BarSeries)(mcChart.Series[0])).ItemsSource = dataPoints.ToArray();
((GanttYAxis)(((BarSeries)(mcChart.Series[0])).IndependentAxis)).DataContext = dataPoints.ToArray();

~Sue

SharePoint Designer 2010 Variable Number of Approvers

I have started my first foray into really getting into SharePoint Designer 2010’s “Start Approval Process” action. 

What I needed to do was to say that X number of people listed in one list had to at any given time approve everything in another list.  Well that really can’t be totally done, it seems, using OOB SharePoint Designer, and that was my requirement – ONLY SharePoint Designer, no custom, no custom SPD Actions.

What I figured I’d do was to have an “upper limit” on the number of people who can approve – say 20.  So I had a custom list of approvers with items numbered 1 thru 20.  If the “Responsible Party” column had a person in it, it should set a task for them, but if that column was blank, it should skip it.

So I figured I’d use the “Start Approval Process” action, because of 2 big reasons – (1) I needed the tasks to run in parallel; and (2) I needed the flexibility of being able to change the emails going out.   I tried the following approaches, all which did not work:

  • One “Start Approval Process” action, with all 20 rows being referenced, figuring that if it was blank, they would skip it (nope)
    • Tried it with returning the user as Login Names
    • Tried it with returning the user as String
  • Several parallel “Start Approval Process” actions, all wrapped around an IF block to say if the field was blank, don’t run it.
    • Tried it with returning the user as Login Names
    • Tried it with returning the user as String
  • Tried hard-coding all of the “Blank” people to the system account.  Then tried the IF blocks around all actions to say if the field was a system account, don’t use it.  (Never matched)

What I finally came up with was a round-about type of procedure.

  1. Create a variable called AllApprovers
  2. FOR EACH one of the 20, did this:
    1. IF Line # x Responsible Party is not blank THEN
      1. IF variable AllApprovers did not contain Line # x Responsible Party (returned as semicolon-delimited Login names)
        1. IF variable AllApprovers was blank
          1. Set variable ApproversVariable to Line # x Responsible Party
        2. ELSE
          1. Set variable ApproversVariable equal to ApproversVariable + “;” + Line # x Responsible Party
  3. IF the variable ApproversVariable is not empty
    1. Start Approval Process and set the Approvers list to the variable AllApprovers
  4. ELSE
    1. Set the workflow to Canceled and stop the workflow.

 

Basically what seemed to be happening is that when the workflow tried to serialize, it tried to convert the Responsible Party into a person.  I kept getting “Coersion” errors.  It seems that if you set the approver list to a variable, it doesn’t try to resolve it till it actually gets to it.

– Sue –