OfficeDevPnP.Core ExtractFields from a list with calculated columns.

Occasional Contributor

Hi All,

 

We would like to use OfficeDevPnP.Core libraries to Remote Provision a site that we have saved off as a template using a call to GetProvisioningTemplate on the web we are interested in.  My group is new to using the PnP.core libraries so likely we are doing something wrong.  

 

Setup is Sharepoint 2013 on Premise.

 

With in the site there are standard lists with calculated columns.  When ever we have a formula on the calculated column that includes a built in formula like Today we get a null exception in the tokenizer for the forumula.  E.g.  We have a column called Days Left and it is a calulated witht he following formula 

=[30 Calendar Days]-Today

 

I download the PnP.core source release from 2/10/2017 and debugged to see that in side TokenizeFieldFormula() it is breaking into tokens the parts of the formula then doing a lookup into the FieldCollection for the list to get the internal name of the field.  In this case it looks up Today and doesn't find it and then tries to use it to replace the internal name but it's null.  It seems to treat everything in the formula as a field, when that isn't the case.

 

  var fieldInternalName = fieldRef.Attribute("Name").Value;
var referencedField = fields.GetFieldByInternalName(fieldInternalName); formulastring = formulastring.Replace($"[{referencedField.Title}]", $"[{{fieldtitle:{fieldInternalName}}}]");

 

 

The question I have is are we doing something wrong that causes the formula parsing on this column to be incorrect?  Seems like something fundamental is off in what we are doing.  

 

Any thoughts on what we could be doing wrong or if this not a supported case?

1 Reply

I think you've catched a bug. I suggest you to submit an Issue in the PnP-Sites-Core GitHub repo or to fix it and perform a pull request.