How to use quotes in a string that contains variables

Hi everyone,
I need to copy this string below, keeping both the single quotes (') and the double quotes ("), and concatenate the string variables into them.
Unfortunately it gives me an error and I can’t get out of it.
Can anyone help me?

‘NameProcess’ = “+processname+” AND ‘Date’ >= “now.tostring” AND ‘conventions’ = “+conventions+” AND ‘NameTask’ = “+nametask+”

I should get this exact text:

‘NameProcess’ = “FIBERLINE” AND ‘Date’ >= “03/05/2024” AND ‘conventions’ = “wholesales” AND ‘NameTask’ = “ACTIVATION”

@AaronMark Where will be you using this query? in SQL or If Activity or any other activity?

Regards,
Ajay Mishra

I need to copy this string into a web tool of my company.

Hey @AaronMark

Use below mentioned query in assign activity:

str_Output = string.Format("'NameProcess' = {0} AND 'Date' >= {1} AND 'conventions' = {2} AND 'NameTask' = {3}", processname,Now.ToString("dd/MM/yyyy"),conventions,nametask)

Screenshot:

Variable Panel:

Regards,
Ajay Mishra

@AaronMark
If you need Values of Variables also in Double Quotes then use below mentioned query in the right side of assign activity:

string.Format("'NameProcess' = ""{0}"" AND 'Date' >= ""{1}"" AND 'conventions' = ""{2}"" AND 'NameTask' = ""{3}""", processname,Now.ToString("dd/MM/yyyy"),conventions,nametask)

Output:
‘NameProcess’ = “FIBERLINE” AND ‘Date’ >= “03/05/2024” AND ‘conventions’ = “Wholesales” AND ‘NameTask’ = “ACTIVATION”

Screenshot:

Regards,
Ajay Mishra

@AaronMark,

Use this in assign activity.

"'NameProcess' = """+processname+""" AND 'Date' >= """+Now.ToString+""" AND 'conventions' = """+conventions+""" AND 'NameTask' = """+nametask+""""

Thanks,
Ashok :slight_smile:

Hi @AaronMark

Assign activity -> processname = "FIBERLINE"

Assign activity -> conventions = "wholesales"

Assign activity -> nametask = "ACTIVATION"

Assign activity -> outputString = "'NameProcess' = """ + processname + """ AND 'Date' >= """ + now.ToString("dd/MM/yyyy") + """ AND 'conventions' = """ + conventions + """ AND 'NameTask' = """ + nametask + """"

Message Box -> outputString

Regards

Autopilot is great for simple activities like this:

image

1 Like