Frequently asked questions
Q: Is there some way to mark which cals in chain are important, and which not (if they failed just keep going)?
A: All chains are important, if one fails then all subsequent requests will be skipped. There is option to make link optional and not skip. More about chaining.
Q: Why in dynamics when I’m using Form.Redirect
, GoErp actually not redirecting to the page?
A: Redirect would trigger only when all the calls in the dynamic request set are succeeded and redirect link is valid. More about dynamic redirect
Q: How to use path parameters to load separate pages?
A: Construct main page as a data router and load html or partials based on path parameters.
/shop/products
/shop/services
{{ if eq .Data.Parameters.path1 "products" }}
{{ template "products-partial" . }}
{{ else if eq .Data.Parameters.path1 "services" }}
{{ template "services-partial" . }}
{{ end }}
Q: Getting the error Template 'my-page' seems to be linking to an external source 'https://my.css' that are currently not allowed
on publish
A: Since there is no security guarantees for outsourced content, it is recommended to use one of the provided methods for storage instead. If nothing is possible then create a whitelist request for the source.
Q: Template breaks on if conditions
A: The if condition is type sensitive, if the input values are of incomparable types then the template rendering will break from that point forward. Make sure the types used have been converted to the correct types EX: (.Int for dynamic responses and toInt for everything else if dealing with integers).
Q: Use multiple if conditions
A: The syntax for multiple if conditions is as follows:
MultiConditionOperator can be “and” or “or”
{{ if {MultiConditionOperator}
({condition1})
({condition2})
}}
Q: Chaining from Session or Parameters does not seem to work
A: The chain syntax values can be different from the values that we use it to print values to the templates. This is due to the internals that chaining works with json and the template print works with structs.
Use toJson helper to find out the correct values that should be used when chaining.
{{ .Session toJson }} <!-- Use the find out what the correct key names are for chaining -->
{{ .Session.User.ID }} <!-- When getting the value to template -->
<input value="Session.user.id"> <!-- When using as a chain value -->
Q: Unable to log into public page
A: Make sure your using the public route path of the page. Customer login does not work with regular handlers.
Q: @pimFilter not working on nested values
A: Make sure the nested values are defined using -> instead of . as the . is reserved here for dynamics.
@pimFilter(name.en,=,string) <!-- incorrect syntax -->
@pimFilter(name->en,=,string) <!-- correct syntax -->
Q: After doing a change operation (create, update or delete) the list of items is not immediately updated (needs another refresh to update)
A: Likely due to incorrect order of dynamic calls. Use ‘|1’ to set the order for the calls and make sure the request that fetches the list is done last.
Q: Not seeing results for created dynamic api calls
A: Either add the errors block (Code samples -> error) to the page or connect the template to an application and check the Application logs tab for results if the calls.
Q: Get current users back office url
A: Users back office link is stored in the session ‘{{ .Session.User.BOLoginUrl }}’
Q: How to concatenate strings and variables using printf
A: printf
is a general go template function that can be used to assemble strings from other
strings and variables. It is mapped to the go function fmt.Sprintf,
which means that it supports all options that are described under Printing topic.
{{ $intVal := 56 }}
{{ $strVal := "foo" }}
{{ $structVal := .Session.Language }}
Result: {{ printf "My int: %d; my string: %s; my struct: %#v" $intVal $strVal $structVal }}
Result
Result: My int: 56; my string: foo; my struct: models.Language{Code:"en", LegacyCode:"eng"}
Q: Where can I get timezone while handling dates in templates?
A: Almost every account have default time related configurations, like timezone and formats. Timezone may not exist for accounts that shares many timezones (e.g. most of the USA accounts), in this case timezone should be configured by account owners.
Available variables:
{{ $timeZone := .Data.ErplyApi.ConfigurationList.timezone }} <!-- Europe/Tallinn -->
{{ $dateFormat := .Data.ErplyApi.ConfigurationList.go_date_format }} <!-- 02.01.2006 -->
{{ $monthDayFormat := .Data.ErplyApi.ConfigurationList.go_month_day_format }} <!-- 02.01 -->
{{ $timeFormat := .Data.ErplyApi.ConfigurationList.go_time_format }} <!-- 15:04:05 -->
{{ $hourMinuteFormat := .Data.ErplyApi.ConfigurationList.go_hour_minute_format }} <!-- 15:04 -->
{{ $dateTimeFormat := .Data.ErplyApi.ConfigurationList.go_date_time_format }} <!-- 02.01.2006 15:04:05 -->