function inside a function project online Odata url query - odata

I am trying to create a Project Online OData URL where I use two functions, one inside the other $filter=substring(ResourceName, indexof(ResourceName,','),10) eq 'example'
substring is the first function and index of is the second function called inside the substring brackets and it returns an integer.
so, I get this message back:
Fehler beim Verarbeiten dieser Anforderung.
and I just want to know why and whether I can do the same some other way

Related

how to pass special character (e.g. %) through url for create new event in google calendar

I am creating a new event in google calendar by the following URL structure.
https://calendar.google.com/calendar/r/eventedit?
text=discount for Asgardian&
dates=20200327T032400Z/20200327T032400Z&
details=Thor will be there to receive you&
location=Asgard&
trp=false&sprop=&sprop=name:
here is a URL variable text, which represents the title of an event.
if I pass a plain string, it works well. but if I pass special character like '%' (e.g. 20% off for Asgardian), then google calendar gave me -
Bad Request
Error 400
how can I pass '%'?
(same error for details vaiable also)
in the comment, #terry gave me answer for how to pass % through URL.
I need to encode it as %25.
he also share that - Javascript has a built-in function for this URL encoding. encodeURIComponent()
if we wrap our string by encodeURIComponent(), it'll give us URL encoded string.
thanks.

Why does intl.Message need to be wrapped in an enclosing function?

Here the a suggested pattern for using Intl.message I have seen everywhere:
final String learnMoreLabel = _learnMoreLabel; String get
_learnMoreLabel => Intl.message('Learn more',
name: 'HelpContentBase__learnMoreLabel',
desc: 'The label for a link or button which takes the user to the '
'Google Help Center to read more information on a topic.');
Why can't I just write:
final String learnMoreLabel = Intl.message('Learn more',
name: 'HelpContentBase__learnMoreLabel',
desc: 'The label for a link or button which takes the user to the '
'Google Help Center to read more information on a topic.');
Why does it need to be wrapped in the getter? I found this in the docs:
Use this for a message that will be translated for different locales.
The expected usage is that this is inside an enclosing function that
only returns the value of this call and provides a scope for the
variables that will be substituted in the message.
but it doesn't say why.
The short answer is that for that example it probably could be written that way, but it breaks down when there are parameters to the message.
What happens with Intl messages is that the a preprocessor runs over the program and finds all the occurrences of Intl.message and writes them to a file. That file gets sent for translation, and then the translations are run through another program and generate Dart code for each language, which is reachable via the messages_all.dart import.
When you call Intl.message at runtime it looks up the current locale (using the name as a key) and delegates to the appropriate translation, passing along any parameters (via the "args" argument).
When the comment says "provides a scope" it really means that the only things that are allowed to be used in the message are the variables that are provided as arguments to the enclosing function. When there aren't any arguments we could allow the enclosing function to be omitted. It would mean making the parser smart enough to recognize that pattern as well.
As an aside: I don't love the pattern of calling the method once and assigning to a final variable. It sets up a potential race condition between locale initialization and variable initialization and it means the locale can't change at runtime. However, I understand when we have frameworks like Angular that are calling it and comparing the result on every frame that it gets expensive to actually call the function every time.
Another aside: When there are no parameters you can omit the name. It will use the text as a name. When there are parameters the text is an interpolation so it can't use that as the name.

Slack slash commands - Variable/Parameters

I'm integrating slack with jenkins to use slash commands and want to know if slash commands have variables
What I want to do is something like this;
/this_word_should_be_in_the_url word
and the be able to use word in the URL the slash command will call.
On their page they have something like /weather 94070
Do I have access to the 94070 and somehow set is as a query parameter for the URL.
Is this possible?
Can't find any documentation of this.
Thanks.
Yes. You will have access to the word as per the example that you mentioned.
So for example, if you have the following:
/this_word_should_be_in_the_url word
Then there will be an additional query parameter named text that will contain everything else after the slash command. If you just have one parameter then it should be simple to just trim and use the text query parameter but if you have multiple words and need to split them into something more meaningful, then you might have to use some regex or simple string split function.
It is documented at How do commands work. In this section they have provided the various query parameters that will get passed to your Slash Command External URL. For the weather example, the data posted as per the documentation is:
token=gIkuvaNzQIHg97ATvDxqgjtO
team_id=T0001
team_domain=example
channel_id=C2147483705
channel_name=test
user_id=U2147483697
user_name=Steve
command=/weather
text=94070
response_url=https://hooks.slack.com/commands/1234/5678
Notice the text parameter in the above list.

Get request URI in jinja2?

I'm working on a Pylons project using Jinja2 templating. I want to test for the request URI and/or controller inside the Jinja2 templates - is there an equivalent to a getRequestUri() call? I can set a context variable as a flag inside all the controller methods to do what I want, but that seems a bit like writing my home address on each and every one of my house keys... i.e. not quite the right way to do it.
Solution: not quite a function call, but I can test against url.environ.PATH_INFO. It only gives me the URL path, not the hostname, and I don't know that it would give me the query string, but it gives me what I need.

is there a simple way to get URL in java

I am working on an email validation link for a website. When a user registers and finishes filling in their personal data (and it passes all the checks), they are sent to a jsp page saying that an email has been sent to the address they entered as the username, with a link to click to validate the email address. So that part is all well and good, I generate the link (for now just using my localhost) and it looks like this as an example http://localhost:9999/javawork/msc/validate/?6FRQ8RAT&u=1s3w1Iih64egX01188HT. When they click the link it goes to the jsp page index.jsp in the validation folder. At this point I need to grab the entire URL and send it to a function to make sure the URL is formatted properly (for security purposes). If it passes and the format is fine, I need to grab the 8 digit code immediately after the '?' and also the value of 'u'. I then send those values to a function that checks that they match what we have in our DB, and if they do, I update the DB record with a validation date so we know they have validated their email address.
So my question is first, how do I grab the entire URL to check the format, and second, how do I grab the 8 digit code, and the value of 'u'? I have been looking online and all examples require creating multiple functions or classes, and using the URL class. And they all want me to make an instance of a URL object and initialize it using the entire URL. But it is not a static URL, it will be different for every user that registers, as it generates a random 8 digit code to check against, and the value of 'u' is the masked user id from the DB. I don't understand how it can require you to initialize the entire URL in order to get the values, when you don't know what the values are until you get them from the URL.
Is there a simple way to grab the values, and the entire URL? Even if I can just get everything after the '?', I know the base URL and can build a new String to check the formatting if I can get from the '?' and after. Please help with that part. Thanks.
The Interface HTTPServletRequest contains a method getRequestURL which returns a StringBuffer which you may use to check the format of the entire URL.
You can get it, in a jsp page with :
<%=request.getRequestURL()%>
If you are using the format of request that you specified above, then your second question :
how do I grab the 8 digit code, and the value of 'u'?
May be answered by manipulating that StringBuffer to split at the ? and & for the 8 digit code.
Or use another request method,
ServletRequest.getParameter(java.lang.String name)
To grab each parameters, though, i'm not certain how it will end up handling the unnamed parameter of the 8 digit code. Let me know how that goes.
Don't think of the 8-digit code as an unnamed parameter. Think of it as a parameter without a value.
request.getParameterNames() will give you the 8-digit code as well as "u". So you can loop through like so:
String code = "";
for(String paramName : request.getParameterNames()) {
if(!paramName.equalsIgnoreCase("u"))
code = paramName;
}

Resources