I don't know whether any out there uses Navision?! but we've recently been lumbered with it and I'm trying to pass a field name dynamically to a function.
Instead of
ModelRec.SETCURRENTKEY(ModelRec.Transmission);
I want to do something like ...
ModelRec.SETCURRENTKEY(ModelRec("FieldName"));
where the string FieldName = "Transmission"
Can anyone point me in the right direction please?
I think you need to write a little more code. In you function, you can say
CASE varFieldname Of
Rec.FIELDNAME(FieldName1):
Rec.SETCURRENTKEY(Fieldset1);
Rec.FIELDNAME(FieldName2):
Rec.SETCURRENTKEY(Fieldset2);
END;
If I understand correctly, you can use: Record.FIELDCAPTION(Field). This will return the name of your field.
Related
I have added custom fields to the news item component in Sitefinity. I am using newsItem.GetValue(customFieldName) to get the value of the field name; however, this is proving to be an issue with translated pages. Is there a way that I can get this value via ID instead? Or how else cna I approach this?
If it is a field that can be translated, then you should use the GetString method instead of GetValue.
Also check this:
https://knowledgebase.progress.com/articles/Article/multilingual-getstring-method-does-not-fallback-for-text-field-values
I need to mock a return value from a specific inner key in my array.
I want to mock this:
CONFIG['key1']['key2']
I thought of doing something like this:
allow(CONFIG).to receive(:[], :[]).with('key1', 'key2').and_return(['my mock'])
but this is not the right way to write it.
Does anyone knows how it should be written?
Thanks!
So finally i found the solution:
allow(CONFIG).to receive_message_chain(:[], :[]).with('key1').with('key2').and_return(['my mock'])
I have a form that I'm creating and to simplify things, I'm trying to create a form field mapper to an object. As such, I create the following dictionary:
self.fieldPropertyMapper = #{
#(CompanyFieldName):self.company,
#(CompanyFieldDescription):self.company.description,
#(CompanyFieldWebsite):self.company.website,
#(CompanyFieldTwitter):self.company.twitter,
#(CompanyFieldAddress):self.company.address,
#(CompanyFieldAddress2):self.company.address2,
#(CompanyFieldCity):self.company.city,
#(CompanyFieldState):self.company.state,
#(CompanyFieldZipcode):self.company.zipcode,
#(CompanyFieldPhone):self.company.phone
};
The keys here are members of the CompanyFieldType enum.
My goal here is to later in my form to assign a value to the returned pointer. Here's what I mean: when a text field in one of my forms stops editing, I'm looking to set the value. Here's what I'd like to accomplish:
- (void)textFieldDidEndEditing:(UITextField *)textField
{
CompanyFieldType fieldType = [self fieldTypeForTag:textField.tag];
// Set the value of the respective company property
// In theory it would be something like:
// self.fieldPropertyMapper[#(fieldType)] = textField.text;
}
I'm assuming there's a way to assign by reference but I'm forgetting how to do this. (Is it using the & symbol or **?) I don't remember. Help appreciated! If I'm messing up my terminology, feel free to let me know.
You can't do exactly what you want to do. That is to say, there is no pointer magic that will do what you want.
You can get essentially the same effect, though, with key-value coding. Instead of storing the result of accessing the property (e.g. self.company.website), instead you want to just store the key path to the value you're interested in as a string — e.g. #"company.website". Then you can do like so:
[self setValue:textField.text forKey:self.fieldPropertyMapper[textField.tag]];
Using NSMapTable initialized with NSPointerFunctionsStrongMemory for the keys and NSPointerFunctionsOpaqueMemory for the values. Then you could store the addresses of your iVars backing your properties as the values in the table.
[self.mapTable setObject:&_company forKey:#(CompanyFieldName)];
Haven't tested this but this should get you started.
In my RazorView i use:
#Html.Editor(prop.PropertyName)
to get the EditorForm. It also creates the Tags: data-val-* with Validationmessages. But in this auto generated Validationmessages the variablename is shown as type.
data-val-number="The field "Int32" must be numeric."
I think this is because the object that cames to the Validationfunction misses the variablename and so he uses the type. So I need to know where the function tries to get the variablenname or which field the function tries to read to fix this.
p.s.
I realy don´t want to change my previous code to fix this, it has his reasons why it is like it is ;-)
The variable name will default to the Property name unless you add a [DisplayName("New Name")] attribute to the Property to change the name used. What type is prop in your example?
I'm using a EntityDataSource with WhereParameters binded from DropDownLists. The Where Clause may be something like this: "it.applicationId = #applicationId" but in that DropDownList i've created a ListItem with Text="All" Value="".
Of course that when the value is "" i don't want to use that value on the query.
How can i do that?
Thank U All
It looks like there is no design time possibility to use parameters optionally.
Try hooking the Selecting event, like it is described in this question.
In your particular case you can get the selected value of the DropDownList (for example, using the FindControl method) and then simply either pass the value of the parameter, or use the query without a Where clause.
you should at first set the attribute "ConvertEmptyStringToNull" in your parameter to true
then type your where condition as follows
"#applicationId IS NULL OR it.applicationId = #applicationId"