Using FieldStart and InsertField

Hi,
I am trying to try the code snippet defined in the following thread :
https://forum.aspose.com/t/83998
Apparently this line is throwing the exception when it’s compiled ('Cannot implicitly convert type… ')

FieldStart start = builder.InsertField("IF \"", null);

May i know what is the correct way of using InsertField method ?
Regards,
hadi teo

Hi,
May i know what is the correct way of using nested field update ? such as this " Nested fields IF { =OR({ COMPARE { =2.5 +PRODUCT(3,5 ,8.4) } > 4}, { =2/2 }) } = 1 "Credit not acceptable" "Credit acceptable" " https://docs.aspose.com/words/net/working-with-fields
Regards,
hadi teo

Hi Hadi,

Thank for your inquiry. You can use the code like below to insert fields nested with an IF field.

Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);

// Insert a few page breaks (just for testing)
for (int i = 0; i < 5; i++)
    builder.InsertBreak(BreakType.PageBreak);

// Move the DocumentBuilder cursor into the primary footer.
builder.MoveToHeaderFooter(HeaderFooterType.FooterPrimary);

// We want to insert a field like this:
// { IF {PAGE} <> {NUMPAGES} "See Next Page" "Last Page" }
Field field = builder.InsertField(@"IF ");
builder.MoveTo(field.Separator);
builder.InsertField("PAGE");
builder.Write(" <> ");
builder.InsertField("NUMPAGES");
builder.Write(" "See Next Page" "Last Page" ");

// Finally update the outer field to recalcaluate the final value. Doing this will automatically update
// the inner fields at the same time.
field.Update();