Use PnP Powershell to export and import list template but prompt column doesn't not exist

Copper Contributor

I am writing pnp powershell in Azure DevOps pipeline to run Export-PnPListToSiteTemplate to export a list to template, and ran Invoke-PnPSiteTemplate to import it to another site. It prompted error message that the column referenced by the formula doesn't exist.

 

I checked the xml file exported, a calculated field's formula refererences another calculated field which was next to it in the xml file. It may be the reason.

<Field Type="Calculated" DisplayName="Collected / Written Off" EnforceUniqueValues="FALSE" Indexed="FALSE" Format="DateOnly" LCID="1033" ResultType="Text" ReadOnly="TRUE" ID="{0c8a6740-fa5c-4cb8-9491-f3bddb013f2b}" SourceID="{{listid:LegalCaseRecord}}" StaticName="CollectedOrWrittenOff" Name="CollectedOrWrittenOff" ColName="sql_variant2" RowOrdinal="0" CustomFormatter="" Required="FALSE" Version="3" IMEMode="inactive">
              <Formula>=IF(AND([Active / Completed]="Active",[Amount Collected]&gt;0,[Amount Written Off]&gt;0),"Collected",IF(AND([Active / Completed]="Completed",[Amount Collected]=0,[Amount Written Off]&gt;0),"Written Off",""))</Formula>
</Field>
<Field Type="Calculated" DisplayName="Active / Completed" EnforceUniqueValues="FALSE" Indexed="FALSE" Format="DateOnly" LCID="1033" ResultType="Text" ReadOnly="TRUE" ID="{0f88a515-5561-468c-a6cc-5f637e314f9e}" SourceID="{{listid:LegalCaseRecord}}" StaticName="ActiveOrCompleted" Name="ActiveOrCompleted" ColName="sql_variant3" RowOrdinal="0" CustomFormatter="" Required="FALSE" Version="7" IMEMode="inactive">
              <Formula>=IF([CaseCompletedFileClose]=FALSE,[ActiveOrCompletedValue],"Completed")</Formula>
</Field>
<Field ClientSideComponentId="00000000-0000-0000-0000-000000000000" CommaSeparator="TRUE" DisplayName="Amount Written Off" Format="HK$123,456.00 (Hong Kong S.A.R.)" LCID="3076" Name="AmountWrittenOff" Title="Amount Written Off" Type="Currency" ID="{0c664d3a-22d9-471d-aaf4-e927bcf76fbd}" Version="18" StaticName="AmountWrittenOff" SourceID="{{listid:LegalCaseRecord}}" ColName="float9" RowOrdinal="0" CustomFormatter="" Required="FALSE" EnforceUniqueValues="FALSE" Indexed="FALSE" IMEMode="inactive">
              <ClientValidationFormula>=if([$ActiveOrCompletedValue]=='Completed','true','false')</ClientValidationFormula>
              <Default>0</Default>
</Field>
 

 

The PnP Powershell module version I used is 1.12.0

 

Is there any idea how to fix this issue? Manually updating the xml file exported is not practical as it is in the pipeline.

0 Replies