I have been using asterisk to connect to adhearsion for my system. System originate call to a sip number by using follow script.
Adhearsion::OutboundCall.originate number,
from: call_from,
controller: controller ,
controller_metadata: {id: #id, initiate_from:'outbound'}
and cdr of asterisk is used to maintain call status. The number that i haved called (destination call number) is not shown in cdr report.:
`id`, `calldate`, `clid`, `src`, `dst`, `dcontext`, `lastapp`, `lastdata`, `duration`, `billsec`, `disposition`, `channel`, `dstchannel`,`amaflags`, `accountcode`, `uniqueid`, `userfield`, `answer`, `end`
'2015-07-03 11:29:21', '9801243867', '9801243867', '1', 'adhearsion-redirect', 'Dial', 'SIP/ncell-out/playback', 5.12455, 5.89977, ' ANSWER', 'SIP/ncell-out-00000002', NULL, 'DOCUMENTATION', NULL, '1435902231.2', NULL, '0000-00-00 00:00:00', '2015-07-03 11:29:21'
'2015-07-03 11:29:26', '9801243867', '9801243867', '1', 'adhearsion-redirect', 'Dial', 'SIP/ncell-out/9771002', 0.000001, 0, 'NO ANSWER', 'SIP/ncell-out-00000003', NULL, 'DOCUMENTATION', NULL, '1435902236.3', NULL, '0000-00-00 00:00:00', '2015-07-03 11:29:26'
Adhearsion call 1#adhearsion-redirect , 1 destination number.
Executing [1#adhearsion-redirect:1] AGI("SIP/ncell-out-00000004", "agi:async")
how should i get destination number in cdr instead of 1 when originate call from adhearsion?
(if I had enough rep to comment, I'd ask you to post your controller code so I know how the call gets to 1#adhearsion-redirect).
Looks like you could use a helper-context to store some data in the CDR before continuing on to the adhearsion-redirect context. The part I'm missing is how to redirect your existing setup to the helper context.
Here's an example of a helper-context. Since I don't know your controller code, you essentially need to make it Dial(Local/1234567890#helper-context) instead of Dial(Local/1#adheasion-redirect). Here's the context:
[helper-context]
exten=_X.,1,Set(CDR(userfield)=${EXTEN})
exten=_X.,n,Goto(1,adhearsion-redirect)
Basically what this does is let any extension match inside helper-context, and sets the "userfield" in the CDR to the number. (You could change this to other CDR fields, but this was NULL in your log, so it was ripe for the picking.) Then it forward on to the adhearsion-redirect context. Using the Dial I showed above, this would set CDR's userfield to 1234567890, or whatever number you wanted to dial.
Related
I've seen the JSON array questions here and I'm still a little lost, so could use some extra help.
Here's the setup:
My Flow calls a sproc on my DB and that sproc returns this JSON:
{
"ResultSets": {
"Table1": [
{
"OrderID": 9518338,
"BasketID": 9518338,
"RefID": 65178176,
"SiteConfigID": 237
}
]
},
"OutputParameters": {}
}
Then I use a PARSE JSON action to get what looks like the same result, but now I'm told it's parsed and I can call variables.
Issue is when I try to call just, say, SiteConfigID, I get "The output you selected is inside a collection and needs to be looped over to be accessed. This action cannot be inside a foreach."
After some research, I know what's going on here. Table1 is an Array, and I need to tell PowerAutomate to just grab the first record of that array so it knows it's working with just a record instead of a full array. Fair enough. So I spin up a "Return Values to Virtual Power Agents" action just to see my output. I know I'm supposed to use a 'first' expression or a 'get [0] from array expression here, but I can't seem to make them work. Below are what I've tried and the errors I get:
Tried:
first(body('Parse-Sproc')?['Table1/SiteConfigID'])
Got: InvalidTemplate. Unable to process template language expressions in action 'Return_value(s)_to_Power_Virtual_Agents' inputs at line '0' and column '0': 'The template language function 'first' expects its parameter be an array or a string. The provided value is of type 'Null'. Please see https://aka.ms/logicexpressions#first for usage details.'.
Also Tried:
body('Parse-Sproc')?['Table1/SiteconfigID']
which just returns a null valued variable
Finally I tried
outputs('Parse-Sproc')?['Table1']?['value'][0]?['SiteConfigID']
Which STILL gives me a null-valued variable. It's the worst.
In that last expression, I also switched the variable type in the return to pva action to a string instead of a number, no dice.
Also, changed 'outputs' in that expression for 'body' .. also no dice
Here is a screenie of the setup:
To be clear: the end result i'm looking for is for the system to just return "SiteConfigID" as a string or an int so that I can pipe that into a virtual agent.
I believe this is what you need as an expression ...
body('Parse-Sproc')?['ResultSets']['Table1'][0]?['SiteConfigID']
You can see I'm just traversing down to the object and through the array to get the value.
Naturally, I don't have your exact flow but if I use your JSON and load it up into Parse JSON step to get the schema, I am able to get the result. I do get a different schema to you though so will be interesting to see if it directly translates.
I am trying to write logic for a search query. There are many different conditions with different parameters. One parameter sent from form is code. So there are code values in two different tables: competitions and responses. What I need is to check the params[:code] value first in competitions table and if it does not exist then check in responses table. If it does not exist in either table then it should return nil. I am trying to write it in a single if statement. The code I tried is below:
competitions = Competition.includes(:event, :responses)
if params[:code].present?
competitions = (competitions.where(code: params[:code])) ||
(competitions.joins(:responses).where(responses: { code: params[:code] }))
The above code checks only the value of competitions.where(code: params[:code]). If that value is [], then it is not evaluating the second condition. What changes should I do to make the above code work as per the requirements mentioned above?
competitions.where(code: params[:code]) returns a Relation object which is always truthy.
Luckily enough, it implements #presence method, returning either the value if it’s not blank, or nil. So, this should work:
competitions.where(code: params[:code]).presence || ...
As part of an email step in our Flow, we are creating an HTML table, where certain rows are hidden using css.
So our expression formula (in the body of the Outlook - Send an email from a Shared Mailbox step looks like this:
if(
And(
Or(
equals(triggerBody()['DD_Artwork']['Value'], 'Bargain New Store')
, equals(triggerBody()['DD_Artwork']['Value'], 'Home & Fashion')
,equals(triggerBody()['DD_Artwork']['Value'], 'Home Store'))
, #empty(triggerBody()?['StoreOpeningDate']))
,'tr.StoreOpenDate {display:visible}', 'tr.StoreOpenDate {display:none}')
this part, checking the Date Selector field StoreOpeningDate is not working:
, #empty(triggerBody()?['StoreOpeningDate']))
we have also tried:
, Not IsBlank(triggerBody()?['StoreOpeningDate']))
and
, Not IsEmpty(triggerBody()?['StoreOpeningDate']))
and even:
, Not equals(triggerBody()?['StoreOpeningDate']), '')
but we always get the error message The expression is invalid
so what's the right way to go about this?
I faced a similar problem. The TriggerBody() function is doing the damage. Just use
Empty(item()?['DateField']) not equal to false in the condition.
How I can user variables in switch controller. I need this kind of logic:
ThreadGroup contains: counter (start with 1000 and ends with 1020, referense name = record_id), httpRequest(use record_id as a parameter), switch controller (switch value = ${record_id}) and inside switch controller I have size assertion named 1000. But this size assertion is't working. How I can make switch controller working with diffrent cases like 1000, 1001 etc (record_id(counter)).
The switch controller must contain samplers or controllers named 1000, 1001, etc. An assertion is not switchable so no point naming it 1000, you need to name the sample that the assertion applies to.
I'm banging my head against the wall on this one. I was looking at some old database reporting code written in VB6 and came across this line (the code is moving data from a "source" database into a reporting database):
rsTarget!VehYear = Trim(Str(rsSource!VehYear))
When rsSource!VehYear is Null, the above line generates an "Invalid use of Null" run-time error. If I break on the above line and type the following in the Immediate pane:
?rsSource!VehYear
It outputs Null. Fine, that makes sense. Next, I try to reproduce the error:
?Str(rsSource!VehYear)
I get an "Invalid use of Null" error.
However, if I type the following into the Immediate window:
?Str(Null)
I don't get an error. It simply outputs Null.
If I repeat the same experiment with Trim() instead of Str(), everything works fine. ?Trim(rsSource!VehYear) returns Null, as does ?Trim(Null). No run-time errors.
So, my question is, how can Str(rsSource!VehYear) possibly throw an "Invalid use of Null" error when Str(Null) does not, when I know that rsSource!VehYear is equal to Null?
Update: If I type the following in the Immediate window, it works as expected (no error occurs):
?Str(rsSource!VehYear.Value)
This outputs Null. Now, I know that rsSource!VehYear is actually an ADODB.Field instance, but Value is its default property, so Str should be operating on the Value property (which is Null). Even the error message ("Invalid use of Null") suggests that Str is receiving a Null parameter, but how can it treat Null differently in one case and not the other?
My only guess is the internal implementation of Str() is somehow failing to get the default property, and the "Invalid use of Null" error is happening for a different reason (something other than the parameter is causing the "Invalid use of Null", perhaps when it is trying to retrieve the default property from the Field object).
Does anyone have a more detailed, technical explanation for what is actually happening here?
In short:
?Str(rsSource!VehYear)
throws an "Invalid use of Null" error when rsSource!VehYear is Null, but
?Str(rsSource!VehYear.Value)
returns Null.
However, both Trim(rsSource!VehYear) and Trim(rsSource!VehYear.Value) return Null.
If you need a value other than a string, try using IsNull instead:
rsTarget!VehYear = IIf(IsNull(rsSource!VehYear), 0, rsSource!VehYear)
' Note 0 is the default value
The Str function will specifically check if a Null value is passed in and deal with it accordingly. When you pass in an object it attempts to convert the result of a default method to a String. The result of the default method is not passed into the Str method, but Field object is, so a check for the initial Null will fail. The Str function will continue to check the parameter type for datatypes that it supports when it realizes that it has an object, it will attempt to retrieve the default value. It doesn't re-attempt to deal with the default value as it did with the passed in argument, so the attempt to return a Null as a String will fail. It seems MS didn't expect a default value to be Null or any other invalid value for Str. For instance Str doesn't support an empty string either.
This was my workaround in the vb6-days:
rsTarget!VehYear = Trim(Str(rsSource!VehYear & ""))
the & "" will make sure there is allways at least an empty string to work with.
From memory, null database fields are Nothing (or possibly vbNull), which do not have the same rules applied to them as Null. You should just be able to do a quick check:
If (rsSource!VehYear Is Nothing) Then
' Null
Else
' Not null
End If