You are viewing limited content. For full access, please sign in.

Question

Question

Is it possible to set a field to required for a particular template using the SDK?

SDK
asked on November 19, 2019

I'm trying to create a large number of templates and fields using the SDK. I'm able to create a basic template and field, but I can't seem to figure out how to make a field required on a certain template. Does anybody have a code sample they can share that shows how to do this? Is it possible to do it as part of the template and field creation process? Here's the code I'm using (basically the block from the tutorial) and while it doesn't throw an error on the NewField.Required line, the field doesn't get the required flag either generally for that specific field.

LFTemplate NewTemp = new LFTemplate();
NewTemp.Create(LfDB, "Test", true);
LFTemplateField NewField = new LFTemplateField();
NewField.Create(LfDB, "Product Number", Field_Type.FIELD_TYPE_STRING, false);
NewField.Required = true;
NewTemp.AddTemplateField(1, NewField);
NewTemp.Update();

 

0 0

Answer

SELECTED ANSWER
replied on November 19, 2019

Call NewTemp.SetFieldRequiredForTemplateByFieldName("Product Number") before calling NewTemp.Update(). This will make the Product Number field required when it is a part of that template.

 

Also, in your code it sets the field to be required globally but it doesn't call NewField.Update() to commit that change.

1 0

Replies

replied on November 19, 2019

Thank you. That worked. I really appreciate your quick response. 

0 0
You are not allowed to follow up in this post.

Sign in to reply to this post.