Logic Apps - How to save a tracked property guid as string? - azure-logic-apps

I want to track a guid value in LogAnalytics, using tracked properties, but I can't get it to be saved as a string (that is with suffix "_s" instead of "_g" for guid).
I've tried to convert it to string and to replace all the hyphens to empty string, but no luck.
It works fine if I concat the guid with another character, but I want to save the guid as it is of course.
Example, this does not work:
trackedProperties": {
"MessageId": "#{string(Outputs('MyAction').MessageId)}"
}
Anyone got an idea of how to solve this?

I think we need to refer to the official document to know the record type and properties.
So could you please check if the "messageId_g" is existed. And if still can't solve it, you can try to use another "Initialize variable" action and put your messageId in it and then tracked the property in "Initialize variable" action, it should be "_s".
Hope it helps~

To identify a property's data type, Azure Monitor adds a suffix to the property name. If a property contains a null value, the property is not included in that record. This table lists the property data type and corresponding suffix:
**RECORD TYPE AND PROPERTIES**
**Property data type Suffix**
String => _s
Boolean => _b
Double => _d
Date/time => _t
GUID (stored as a string) => _g

Related

Comparing Old and new value of the record

Hope you are all doing good!!!.
I just need to fix this one and I googled the logic and when I tried I got an error and then I have copied the online code and paste that too but no use.
the logic of the below code is :Check the phone number of the account and compare old and new value of the phone number if it's not the same value then I need to update the old value in the description.
public class CheckOldAndNewValueonAccount {
public static void accNewOldValues(List<Account> accList){
for(Account acc: accList){
Account oldAcc = Trigger.oldMap.get(acc.Id);
if(acc.Phone != oldAcc.Phone){
acc.Description = 'Old Phone number this account is :'+oldAcc.Phone;
}
}
}
}
Error: Illegal assignment from SObject to Account.
Please guide me on this.
Thanks in Advance.
I believe the issue is this line:
Account oldAcc = Trigger.oldMap.get(acc.Id);
I believe the type of old map is Map<String, sObject>.
sObject is a type that is a Salesforce object (any one) but none specifically.
So you are trying to assign an sObject to a variable you are declaring as an Account type.
You can just do the following:
sObject oldAcc = Trigger.oldMap.get(acc.Id);
unless you specifically want to try and cast the sObject to an Account (concrete) type. I don't see any major benefit to doing so. Let us know if that was the problem and if this resolved it.
Edit: see this trailhead:
https://trailhead.salesforce.com/en/content/learn/modules/apex_database/apex_database_sobjects
Section: Casting Generic sObjects to Specific sObject Types
You can easily cast to Account. There is a snippet there.
Dot notation is not available on generic sObject types.
Or you can use .get('fieldname') which works on generic sObject as well.

kotlin "contains" doesn't work as expected

I am working with a method which filters the preferences which match with the ids, I am using the contains method, but even though the values are the same, the contains is showing a false in each iteration. The method looks like:
private fun filterPreferencesByIds(context: MyPodCastPresenterContext): List<FanPreferences> {
return context.preferences?.filter {
context.ids.contains(it.id)
}
}
The values of the arrays are:
for the context.ids:
"B52594F5-80A4-4B18-B5E2-8F7B12E92958" and "3998EDE7-F84B-4F02-8E15-65F535080100"
And for the context.preferences:
But even though, when the first and the final ids have the same id value as the context.ids, the contains is false in the debug. I think it could be related with the types in the context.ids rows Json$JsonTextNode. Because when I did the same with numeric values hardcoded the compare is successful.
Any ideas?
Thanks!
If the type of FanPreferences.id is String and the type of context.ids list element is JsonTextNode, you won't find an element equal to the given id string, because it's not of String type.
Try mapping your context ids to the list of strings before filtering:
val ids = context.ids.map { it.toString() }.toSet()
return context.preferences?.filter {
ids.contains(it.id)
}
Note that calling toString() on JsonTextNode might be not the best way to get the string data from it. It's better to consult the API documentation of that class to find it out.

Put settings from file into different strings

I have a document containing settings for a program like so
setting1;value1;
setting2;value2;
setting3;value3;
I want to loop through these lines, assigning value1 from setting1 to a string named the same (setting1). So that the strings value will be value1.. Hope you get me ?
How can i do this?
Thanks!
Most sensible way is to store therm in a Dictionary:
// untested
Dictionary<string,string> settings =
File.Readlines("filename")
.Select(line => line.Split(";"))
.ToDictionary(parts => parts[0], parts => parts[1]);
// usage:
string value1 = settings["setting1"];
If you really want to assign them all to named fields or properties (but not: variables) in one go then you will need Reflection.
Are you reading in a lot of these? If there are only a couple, variables might work but if there are a lot, a dictionary or similar might be a good choice. http://msdn.microsoft.com/en-us/library/xfhwa508%28v=vs.110%29.aspx or http://www.dotnetperls.com/dictionary
You would just need to change your loop to add a new dictionary entry instead - use the 'setting' as the key and the value as the value.

Named properties for CALENDER items

I want to know whether I have to fetch PropertyID for PidLidAppointmentDuration using GetNamesFromIDs(), like the way we do for Named-Property.
http://msdn.microsoft.com/en-us/library/cc433490%28v=exchg.80%29.aspx
2.11 PidLidAppointmentDuration
Canonical name: PidLidAppointmentDuration
Description: Specifies the length of the event, in minutes.
Property set: PSETID_Appointment {00062002-0000-0000-C000-000000000046}
Property long ID (LID): 0x00008213
Data type: PtypInteger32, 0x0003
Here microsoft gives PropertyID right way. So can I use 0x8213 directly without calling GetNamesFromIDs(). More importantly, will 0x8213 work in every environment.
Thanks
Ramesh
This is not at all what it means: property id here is what you pass (along with the GUID) when calling GetIdsFromNames.

How do I iterate through a dictionary and assign the value of each key to the matching property in another object?

I am trying to iterate over a dictionary and an entity. Where the dict key matches the entity property I want to assign the key's value to be the value of the property.
My model code is:
class myModel(db.Model):
Property1 = db.IntegerProperty()
Property2 = db.StringProperty(required=True,choices=set(["this", "that", "other"]))
Property3 = db.StringProperty()
My dict is:
{u'Property1': u'1234', u'Property2': u'trouble', u'Property3': u'2321'}
The code that I am using to iterate through both objects works, however it is skipping the validation in the model. If I explicitly assign myModel.Property2 = 'trouble' I receive a BadValueError. However, in the code below I do not.
for le_attr, le_value in myModel.__dict__.iteritems():
for key, value in Data[0].items():
if ('_' + str(key)) == (str(le_attr)):
myModel.__dict__[le_attr]= value
My thoughts are that no matter how many keys are in the dictionary, only the ones that match the properties will be assigned and all others ignored. With the code above, this works.
But is there a way to do this and still have the validation occur?
You need to use the dir() and setattr() functions instead of poking into the __dict__ structure:
for le_attr in dir(myModel)
if le_attr in Data[0]:
setattr(myModel, le_attr, Data[0][le_attr])

Resources