GoogleAds conversion action with custom value - google-ads-api

I'm try to create new conversion action that the value in UI will be "Use different values for each conversion"
I'm using add_conversion_action.py from example.
In the value_settings I set:
value_settings.default_value = 0.0
value_settings.always_use_default_value = True
But in the UI I got "Don't use a value for this conversion action (not recommended)"
I try to look for answer on developers.google but all looks fine.
Thanks!
The code from example:
# [START add_conversion_action]
def main(client, customer_id):
conversion_action_service = client.get_service("ConversionActionService")
# Create the operation.
conversion_action_operation = client.get_type("ConversionActionOperation")
# Create conversion action.
conversion_action = conversion_action_operation.create
conversion_action.name = f"Earth to Mars Cruises Conversion {uuid.uuid4()}"
conversion_action.type_ = (
client.enums.ConversionActionTypeEnum.UPLOAD_CLICKS
)
conversion_action.category = (
client.enums.ConversionActionCategoryEnum.DEFAULT
)
conversion_action.status = client.enums.ConversionActionStatusEnum.ENABLED
conversion_action.view_through_lookback_window_days = 15
# Create a value settings object.
value_settings = conversion_action.value_settings
value_settings.default_value = 0.0
value_settings.always_use_default_value = True
# Add the conversion action.
conversion_action_response = (
conversion_action_service.mutate_conversion_actions(
customer_id=customer_id,
operations=[conversion_action_operation],
)
)
print(
"Created conversion action "
f'"{conversion_action_response.results[0].resource_name}".'
)
# [END add_conversion_action]

Because you used
value_settings.default_value = 0.0
value_settings.always_use_default_value = True
To set "Use different values for each conversion", value_settings.always_use_default_value must be False.
value_settings.always_use_default_value = False

Related

How to fix: attempt to index nil with 'entered'

So basically, the script is supposed to load text after the intro screen disappears, not sure what's wrong with it because it worked back in 2014 :/
The Code:
if true then
script.Parent.slowsleigh:Play()
fadegui({intro.load},{0},{1},30)
wait(1)
local titles = intro.titles
local text1 = titles.title1.Text
local text2 = titles.title2.Text
local text3 = titles.title3.Text
local text4 = titles.title4.Text
if GameData.entered == 1 then
text1 = "And you came back."
text2 = "You can't change the past."
text3 = "Pathetic."
end
titles.title1.Text = ""
titles.title2.Text = ""
titles.title3.Text = ""
titles.title4.Text = ""
--[
titles.title1.Visible = true
for i = 1, #text1 do
titles.title1.Text = string.sub(text1,1,i)
wait(0.05 + math.random(-5,10)/200)
end
And heres the script inside of ServerScriptServices
local data = game:GetService("DataStoreService"):GetGlobalDataStore()
local dataVersion = 2
local func = Instance.new("RemoteFunction",workspace)
func.Name = "GetData"
function func.OnServerInvoke(player)
local store = data:GetAsync(tostring(player.UserId))
return store
end
local set = Instance.new("RemoteEvent",workspace)
set.Name = "SetData"
set.OnServerEvent:connect(function(player,newData)
local store = data:GetAsync(tostring(player.UserId))
for i,v in pairs(newData) do
store[i] = v
end
data:SetAsync(player.UserId, store)
end)
The Error:
17:48:57.908 Players.Trl0_P90.PlayerGui.maingui.mainscript:758: attempt to index nil with 'entered' - Client - mainscript:758
The error is telling you that you are trying to access GameData.entered, when GameData is nil.
From the code you have shared, your issue appears to be that you are accessing data from the data store and not accounting for the fact that it might not exist. Take a look at the docs for GlobalDataStore:GetAsync() :
This function returns the latest value of the provided key and a DataStoreKeyInfo instance. If the key does not exist or if the latest version has been marked as deleted, both return values will be nil.
This could be caused by a new player joining, and there being no default data. So, one thing you could do is set up some default data in case there's a new player:
local func = Instance.new("RemoteFunction",workspace)
func.Name = "GetData"
function func.OnServerInvoke(player)
local store = data:GetAsync(tostring(player.UserId))
-- if there is no data, it might be a new player!
-- provide some new player data
if not store then
store = {
entered = 1,
foo = true,
bar = "blah",
}
end
return store
end
This way, the function will always return the correctly shaped data.

Control line breaks in F# code formatted by Fantomas

I would like more control and customisation regarding where Fantomas inserts or remove a line break in the code that's formatted by Fantomas. For instance, the following function is formatted in one line but I would prefer having a line break.
module Xxx =
// Actual
let private emptyOrTrimmed (code: string) = if code = null then "" else code.Trim()
// Expected
let private emptyOrTrimmed (code: string) =
if code = null then "" else code.Trim()
How is it possible, preferably without touching the .editorconfig file (given below) ?
Can we add some comment in the code to disable one rule like it exists for eslint ?
// .editorconfig file
root = true
[*]
indent_style = space
indent_size = 4
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = false
[*.fs]
end_of_line = lf
max_line_length = 210
fsharp_semicolon_at_end_of_line = false
fsharp_space_before_parameter = true
fsharp_space_before_lowercase_invocation = true
fsharp_space_before_uppercase_invocation = false
fsharp_space_before_class_constructor = false
fsharp_space_before_member = false
fsharp_space_before_colon = false
fsharp_space_after_comma = true
fsharp_space_before_semicolon = false
fsharp_space_after_semicolon = true
fsharp_indent_on_try_with = false
fsharp_space_around_delimiter = true
fsharp_max_if_then_else_short_width = 40
fsharp_max_infix_operator_expression = 50
fsharp_max_newline_infix_operator_expression_number_of_items = 1
fsharp_multiline_infix_multiline_formatter = character_width
fsharp_max_record_width = 40
fsharp_max_record_number_of_items = 1
fsharp_record_multiline_formatter = character_width
fsharp_max_array_or_list_width = 40
fsharp_max_array_or_list_number_of_items = 1
fsharp_array_or_list_multiline_formatter = character_width
fsharp_max_value_binding_width = 40
fsharp_max_function_binding_width = 40
fsharp_max_dot_get_expression_width = 50
fsharp_multiline_block_brackets_on_same_column = false
fsharp_newline_between_type_definition_and_members = false
fsharp_keep_if_then_in_same_line = true
fsharp_max_elmish_width = 10
fsharp_single_argument_web_mode = false
fsharp_align_function_signature_to_indentation = false
fsharp_alternative_long_member_definitions = true
fsharp_disable_elmish_syntax = false
fsharp_strict_mode = false
Just change this setting to assign it to zero:
fsharp_max_function_binding_width=0
Currently, I've managed to "force a line break" where I want, just by putting a comment in the code. In order to be explicit, the comment is // force-line-break, which looks like a "configuration comment" (e.g. for ESLint) but the comment can be anything.
But I still have no way to do the opposite: forcing no line break, which is occurring very often with record object.
Note: for me the most annoying thing with this code formatting is to have several blocks of code doing something similar but not formatted the same way regarding line breaks, which is breaking the symmetry and is penalizing the code scanning (meaning fast reading, where visual similarities help).

How to handle params conditions in ruby on rails

I want to apply multiple conditions for paraams, I have a below code:
if !params[:parametersSch].blank?
#dynamicDegree = params[:parametersSch]
#dynamicFrom = params[:ParametersFromSch]
#dynamicTo = params[:ParametersToSch]
In the above code "parametersSch" is my text_field name, "ParametersFromSch" is a dropdown name that have years and "ParametersToSch" is also dropdown that also have years and the above code working fine that if params[:parametersSch] is not equal to blank then it puts values in vaiables, but when this condition is false means params[:parametersSch] is equal to blank then I puts empty string in a variables i.e below:
#dynamicDegree = ''
#dynamicFrom = ''
#dynamicTo = ''
But its not working, Kindly suggest me. Thanks
try this
if params.has_key?(:parametersSch) && params[:parametersSch].present?
#dynamicDegree = params[:parametersSch]
#dynamicFrom = params[:ParametersFromSch]
#dynamicTo = params[:ParametersToSch]
else
#dynamicDegree = nil
#dynamicFrom = nil
#dynamicTo = nil
end

Is there an easier way than an "elseif marathon"?

How do I optimize this code?
variable = 1
moveLine = function ()
if variable == 1 then
first = color_1.color
second = color_2.color
elseif variable == 2 then
first = color_2.color
second = color_3.color
end
variable = variable + 1
end
The function is alot longer and that is why I could use an easier way :)
You should be storing your colors in an array:
colors = { all your colors }
moveLine = function()
first = colors[variable]
second = colors[variable + 1]
variable = variable + 1
end

dao recordset updating the wrong record

I'm trying to have a form usable for both creating a new record or updating another. Currently it is doing it through the value of a textbox (new or edit). The structure works fine, but for some reason, when it is performing the edit function, it is saving changes to the wrong record. For instance, if I am editing record 1027, when i submit it, it'll update record 1073. Its consistent, it'll always update the same, wrong record. Edit 1000, it'll update 1073; if i update 1081, it'll update 1073, and so on. Is there a way to specify which record it should be editing? yes, the record number is the primary key/id. Heres the code:
Private Sub btnSubmit_Click()
Dim db As DAO.Database
Dim rs As DAO.Recordset
Dim strTable As String
Dim strField As String
Dim ID As Long
Dim newID As Long
strTable = "record_holdData"
Set db = CurrentDb
Set rs = db.OpenRecordset(strTable)
'button has 2 modes
If txtMode.Value = "NEW" Then
With rs
.AddNew
.Fields("PO_no") = txtPONum
.Fields("prodSupervisor") = cboProdSup
.Fields("qaSupervisor") = cboQASup
.Fields("labTech") = cboLabTech
.Fields("flavor") = cboFlavor
.Fields("lineNumber") = cboLineNumber
.Fields("container") = cboContainer
.Fields("package") = cboPackage
.Fields("holdQty") = txtQty
.Fields("productionDate") = txtProdDate
.Fields("dateCode") = txtDatecode
.Fields("component") = cboComponent
.Fields("nonconformance") = cboDiscrepancy
.Fields("foundDuring") = cboFoundAt
.Fields("responsibility") = cboRespCode
.Fields("comments") = txtDescription
.Fields("rootCause") = txtRootCause
.Fields("holdStatus") = 1
.Fields("dateOpened") = Now()
.Update
.Bookmark = .LastModified
newID = !ID
End With
MsgBox ("Hold information saved!")
btnPrintTag.Enabled = True
DoCmd.OpenReport "Holdtag", acViewPreview, , "[ID] = " & newID
DoCmd.Close
ElseIf txtMode.Value = "EDIT" Then
'do editing stuff
With rs
.Edit
.Fields("PO_no") = txtPONum
.Fields("prodSupervisor") = cboProdSup
.Fields("qaSupervisor") = cboQASup
.Fields("labTech") = cboLabTech
.Fields("flavor") = cboFlavor
.Fields("lineNumber") = cboLineNumber
.Fields("container") = cboContainer
.Fields("package") = cboPackage
.Fields("holdQty") = txtQty
.Fields("productionDate") = txtProdDate
.Fields("dateCode") = txtDatecode
.Fields("component") = cboComponent
.Fields("nonconformance") = cboDiscrepancy
.Fields("foundDuring") = cboFoundAt
.Fields("responsibility") = cboRespCode
.Fields("comments") = txtDescription
.Fields("rootCause") = txtRootCause
.Fields("lastEditDate") = Now()
.Update
End With
MsgBox ("Information Updated")
End If
End Sub
Sorry i caught it. Problem was I was basically redefining the recordset each time the subroutine was called. I changed the second block to the following:
ElseIf txtMode.Value = "EDIT" Then
'do editing stuff
Set rs = db.OpenRecordset("SELECT * FROM record_holdData WHERE ID=" & txtID)
With rs
.Edit
.Fields("PO_no") = txtPONum
.Fields("prodSupervisor") = cboProdSup
.Fields("qaSupervisor") = cboQASup
.Fields("labTech") = cboLabTech
.Fields("flavor") = cboFlavor
.Fields("lineNumber") = cboLineNumber
.Fields("container") = cboContainer
.Fields("package") = cboPackage
.Fields("holdQty") = txtQty
.Fields("productionDate") = txtProdDate
.Fields("dateCode") = txtDatecode
.Fields("component") = cboComponent
.Fields("nonconformance") = cboDiscrepancy
.Fields("foundDuring") = cboFoundAt
.Fields("responsibility") = cboRespCode
.Fields("comments") = txtDescription
.Fields("rootCause") = txtRootCause
.Fields("lastEditDate") = Now()
.Update
End With

Resources