Showing results for 
Show  only  | Search instead for 
Did you mean: 
New Member

LTI Variable Replacement as part of a custom field

Hello Devs,

I'm currently trying to see if it would be possible to utilize Canvas' lti variable substitution in a probably unique kind of way.  We currently have our tool using variable substitution with custom fields just fine when the variable is the only value in the field, however I would like to substitute the variable as part of a value in the field.

For instance, we are currently passing in the context label as such


This works fine, however when I try to include the variable with other information as well, it doesn't work:


The tool launches fine, however looking at what is being sent in the url, it is not replacing the variable, or even trying since there is a %24 code before the com.instructure.contextLabel part, seeming to me that it is trying to pass along the '$', whereas the documentation for lti variable substitution says that it would pass on just the name of the replacement variable if it failed the substitution (ie. in this case it should be sending 'com.instructure.contextLabel' instead of '$com.instructure.contextLabel')

I suppose my main question is whether there exists a way to use variable substitution as I have described in the 'tool' code line?  Is variable substitution only processed if it's the only value in the field?



Labels (2)
5 Replies
Community Champion

It looks like you cannot do this.  If you need to be able to specify the static bit per placement, rather than statically or per consumer key at the tool end, then you could use two custom variables (one for the url bit and one for the Canvas variable) and put them together in the tool.

BTW, I think the bit in brackets in the docs is slightly mis-leading, the main bit is "... it will just send the variable as if it were are regular custom variable" --- which means everything to the right of the equals, so the $ does get sent.  E.g., if you use $ and you are not masquerading, it will send $  Just as if you have $SomethingIMadeUp it will send $SomethingIMadeUp

Community Champion

Actually, you can do this, try un-documented curly brackets:


This works as you mentioned.  Interesting that the documentation prefers the un-bracketed version of using variables.  I'm going to write a separate post about my findings with using url manipulation with external tools.  Thanks!

0 Kudos
Community Contributor

Just chiming in for people finding this, more uses for string concatenation with a custom LTI value.

For example in order to make sure that the correct version of a user's email (for us this is what in shibboleth is eppn, or eduPersonPrincipalName) is passed no matter what, we add the custom value like this:


and then set the tool provider to use custom_eppn as the email address.

Note: This will pass all Test students and any other user account that doesn't have an sis_id as having an email address when they normally don't, i.e. test students would have an email address like, and a non sis_account will be passed as

This can be avoided by instead using a formulation like


However, this might have a stranger effect on LTI launches as all users with out an sisSourceId will be passed with custom_sis_eppn = ${Canvas.user.sisSourceId}, which might cause errors on the other side as ${Canvas.user.sisSourceId} is not a valid email adddress (and if the tool provider accepts it, all non-sis accounts might share an account on the Tool Provider's side, depending on how they implemented their LTI (for the many vendors who use email as their primary account id, this would definitely happen). 

This seems to be a side effect of the the concatenation -- using a simple variable sub instead, i.e.


is passed as custom_sis_user_id="" for users without a sisSourceId.


You can do multiple values in a single line, e.g.


0 Kudos
Community Member

This was great information. 

I was wondering if you can do the reverse as well? We have the following problem:

Due to "reasons" our login-ids are in the form in Canvas but in most other services it is, So I want to extract the CID (Chalmers ID) and add "".

Does anyone know if this is possiblem?

Best regards


0 Kudos