Want to retrieve random value from the response - jmeter

I have the following response payload and there are 4 siteId and I want to select any random siteId from it. This value of 4 can be change it will random, irrespective of it i want to select any random siteId.
Response Value
{
"studyDTO": {
"studyId": 191,
"studyCode": null
},
"sites": [
{
"studyId": 191,
"siteRecid": 1,
"siteId": "10000"
},
{
"studyId": 191,
"siteRecid": 16521,
"siteId": "11001"
},
{
"studyId": 191,
"siteRecid": 16632,
"siteId": "11011"
},
{
"studyId": 191,
"siteRecid": 201,
"siteId": "20000"
}
],
"subjects": [],
"visits": [],
"sftpLocations": [],
"dicomLocations": [],
"fileSystemLocations": [],
"rawFileSystemLocations": [],
"states": [],
"modalities": [],
"examDates": [],
"series": [],
"transferType": null,
"customFolder": false,
"customFile": false,
"folderStructure": null,
"fileStructure": null,
"allSites": false,
"allSubjects": false,
"allVisits": false,
"allStates": false,
"allExamDates": false,
"allModalities": false,
"allSeries": false,
"softEditOverride": false,
"includePS": false,
"includeSR": false,
"includeRTStruct": false,
"dicomTemplate": null,
"errorMessage": null,
"successMessage": null
}

Add JMESPath Extractor to your sampler and configure it:
JMESPath expressions: sites[*].studyId
Match No.: 0
Default Values: STUDYID_NOT_FOUND
JMESPath Extractor will collect all the studyId values and return one selected randomly.

Related

How to return consistent data types in laravel pagination

I have a function that returns staff and there associated attributes as below
foreach ($merchant_user_ac->staffs->sortByDesc('id') as $staff) {
$wage = Staff::find($staff->id)->totalCommissions($start_date, $end_date);
$payments = StaffPayment::where('merchant_id', AH::cMiD())
->where('user_id', $staff->id)
->when(!empty($start_date) && !empty($end_date), function ($q) use (
$start_date,
$end_date
) {
$q->whereBetween(\DB::raw('date(payment_date)'), [
$start_date,
$end_date,
]);
})
->sum('amount');
$balance_owed = $wage - $payments;
$transactions->add([
'id' => $staff->id,
'name' => $staff->name,
'profilephoto' => $staff->profilephoto,
'wage' => $wage,
'payments' => $payments,
'salary' => $staff->salary,
'rent' => $staff->rent,
'balance_owed' => $balance_owed + $staff->salary - $staff->rent,
]);
}
$merchant_staffs = collect(json_decode(json_encode($transactions), false));
$merchant_staffs = $merchant_staffs->paginate(10);
return response()->json($merchant_staffs);
In the results, the first page is OK but the subsequent pages are having a different data type from the first page and displaying the data becomes an issue.
The data key has different data types.
I have tried paginating before the foreach loop but the response did not have the pagination links.
I have tried adding ->toArray() method when collecting the data but has the same issue of different types.
How can I return the same data in all pagination links?
The data returned is as below
{
"current_page": 1,
"data": [
{
"id": 532,
"name": "George2",
"profilephoto": "photos/GwSIKoIXUk1GdL7boD7Ht9mSp1loxM1nGcZ5l5Gd.jpg",
"wage": 0,
"payments": 10000,
"salary": "90000.00",
"rent": "1000.00",
"balance_owed": 79000
},
{
"id": 528,
"name": "david",
"profilephoto": null,
"wage": 100,
"payments": 0,
"salary": "67000.00",
"rent": "67000.00",
"balance_owed": 100
},
{
"id": 524,
"name": "Naggie",
"profilephoto": null,
"wage": 0,
"payments": 0,
"salary": null,
"rent": null,
"balance_owed": 0
},
{
"id": 503,
"name": "Khaki ",
"profilephoto": null,
"wage": 0,
"payments": 0,
"salary": null,
"rent": null,
"balance_owed": 0
},
{
"id": 502,
"name": "Susan",
"profilephoto": null,
"wage": 0,
"payments": 0,
"salary": null,
"rent": null,
"balance_owed": 0
},
{
"id": 476,
"name": "Maggie",
"profilephoto": null,
"wage": 0,
"payments": 17000,
"salary": null,
"rent": "15000.00",
"balance_owed": -32000
},
{
"id": 475,
"name": "Aggy",
"profilephoto": null,
"wage": 0,
"payments": 15000,
"salary": "15000.00",
"rent": null,
"balance_owed": 0
},
{
"id": 465,
"name": "Rhoda",
"profilephoto": null,
"wage": 0,
"payments": 0,
"salary": null,
"rent": null,
"balance_owed": 0
},
{
"id": 464,
"name": "Very New Staff",
"profilephoto": null,
"wage": 500,
"payments": 0,
"salary": "10000.00",
"rent": null,
"balance_owed": 10500
},
{
"id": 422,
"name": "jane",
"profilephoto": null,
"wage": 0,
"payments": 0,
"salary": "15000.00",
"rent": null,
"balance_owed": 15000
}
],
"first_page_url": "http://127.0.0.1:8000/api/v1/staff/list?page=1",
"from": 1,
"last_page": 3,
"last_page_url": "http://127.0.0.1:8000/api/v1/staff/list?page=3",
"links": [
{
"url": null,
"label": "« Previous",
"active": false
},
{
"url": "http://127.0.0.1:8000/api/v1/staff/list?page=1",
"label": "1",
"active": true
},
{
"url": "http://127.0.0.1:8000/api/v1/staff/list?page=2",
"label": "2",
"active": false
},
{
"url": "http://127.0.0.1:8000/api/v1/staff/list?page=3",
"label": "3",
"active": false
},
{
"url": "http://127.0.0.1:8000/api/v1/staff/list?page=2",
"label": "Next »",
"active": false
}
],
"next_page_url": "http://127.0.0.1:8000/api/v1/staff/list?page=2",
"path": "http://127.0.0.1:8000/api/v1/staff/list",
"per_page": 10,
"prev_page_url": null,
"to": 10,
"total": 25
}
Try
$pagination = $merchant_user_ac->staffs()->latest()->paginate(10);
$data = $pagination->getCollection()->map(function ($staff) {
$wage = Staff::find($staff->id)->totalCommissions($start_date, $end_date);
$payments = StaffPayment::where('merchant_id', AH::cMiD())
->where('user_id', $staff->id)
->when(!empty($start_date) && !empty($end_date), function ($q) use (
$start_date,
$end_date
) {
$q->whereBetween(\DB::raw('date(payment_date)'), [
$start_date,
$end_date,
]);
})
->sum('amount');
$balance_owed = $wage - $payments;
return [
'id' => $staff->id,
'name' => $staff->name,
'profilephoto' => $staff->profilephoto,
'wage' => $wage,
'payments' => $payments,
'salary' => $staff->salary,
'rent' => $staff->rent,
'balance_owed' => $balance_owed + $staff->salary - $staff->rent,
];
});
return response()->json($pagination->setCollection($data));
}

Form a JSON request using previous response value in JMETER

On my request I am getting the following response,
{
"studyDTO": {
"studyId": 191,
"studyCode": "test_ispptest2"
},
"sites": [],
"subjects": [],
"visits": [],
"sftpLocations": [],
"dicomLocations": [],
"fileSystemLocations": [],
"rawFileSystemLocations": [],
"states": null,
"modalities": [
{
"studyId": 191,
"submitValue": "ct",
"displayValue": "Conventional CT",
"orderOfDisplay": 30
},
{
"studyId": 191,
"submitValue": "multi_slice_spiral_ct",
"displayValue": "Multi-Slice Spiral CT",
"orderOfDisplay": 50
},
{
"studyId": 191,
"submitValue": "dxa",
"displayValue": "DXA",
"orderOfDisplay": 60
},
{
"studyId": 191,
"submitValue": "mri",
"displayValue": "MRI",
"orderOfDisplay": 100
},
{
"studyId": 191,
"submitValue": "unknown",
"displayValue": "Unknown",
"orderOfDisplay": 240
}
],
"examDates": [],
"series": null,
"transferType": null,
"customFolder": false,
"customFile": false,
"folderStructure": null,
"fileStructure": null,
"allSites": true,
"allSubjects": true,
"allVisits": true,
"allStates": false,
"allExamDates": true,
"allModalities": false,
"allSeries": false,
"softEditOverride": false,
"includePS": false,
"includeSR": false,
"includeRTStruct": false,
"dicomTemplate": null,
"errorMessage": null,
"successMessage": null
}
in the response I received 5 modality value this can be more and in my next request body in the JSON type I want to add all the modalities, how I can do this using JSR223 Post-Processer,
Request Sample:
{
"studyDTO": {
"studyId": 191,
"studyCode": "test_ispptest2"
},
"allVisits": true,
"modalities": [
{
"studyId": 191,
"submitValue": "ct",
"displayValue": "Conventional CT",
"orderOfDisplay": 30
},
{
"studyId": 191,
"submitValue": "multi_slice_spiral_ct",
"displayValue": "Multi-Slice Spiral CT",
"orderOfDisplay": 50
},
{
"studyId": 191,
"submitValue": "dxa",
"displayValue": "DXA",
"orderOfDisplay": 60
},
{
"studyId": 191,
"submitValue": "mri",
"displayValue": "MRI",
"orderOfDisplay": 100
},
{
"studyId": 191,
"submitValue": "unknown",
"displayValue": "Unknown",
"orderOfDisplay": 240
}
],
"includePS": null
}
I have developed so far, but don't have a clue to form the request JSON
import groovy.json.JsonSlurper
def jsonString = prev.getResponseDataAsString();
def jsonConvert = new JsonSlurper();
def object = jsonConvert.parseText(jsonString);
def modalityS = object.modalities.size().toString();
def modalitySize = modalityS?.isInteger() ? modalityS.toInteger() : null
for (int i = 0; i < modalitySize ; i++) {
def modalityOrderOfDisplay = object.modalities[i].orderOfDisplay;
def modalSubmitValue = object.modalities[i].submitValue;
def modalDisplayValue = object.modalities[i].displayValue;
log.info('----------------------->'+modalityOrderOfDisplay);
log.info('----------------------->'+modalSubmitValue);
log.info('----------------------->'+modalDisplayValue);
}
Take a look at JsonBuilder class
Something like:
def response = new groovy.json.JsonSlurper().parse(prev.getResponseData())
def request = [:]
request.put('studyDTO', response.studyDTO)
request.put('allVisits', response.allVisits)
request.put('modalities', response.modalities)
request.put('includePS', null)
vars.put('request', new groovy.json.JsonBuilder(request).toPrettyString())
should do the trick for you.
You will be able to refer the generated request body as ${request} where required.
More information:
Apache Groovy - Parsing and producing JSON
Apache Groovy: What Is Groovy Used For?

Is there any information about the possibility of creation entity records in EntityMetadata?

Here is the documentation EntityMetadata EntityType where all the properties of an entity are described.
I can not find any property that can describe the possibility to create a record of this entity type there.
How can I figure out that this entity type supports the creation of records?
As an example - activitypointer EntityType supports only Operations Supported GET, but in the entity metadata description, there is nothing related to it.
ActivityPointer EntityMetadata
{
"ActivityTypeMask": 1,
"AutoCreateAccessTeams": false,
"AutoRouteToOwnerQueue": false,
"CanBeInCustomEntityAssociation": {
"CanBeChanged": false,
"ManagedPropertyLogicalName": "canbeincustomentityassociation",
"Value": false
},
"CanBeInManyToMany": {
"CanBeChanged": false,
"ManagedPropertyLogicalName": "canbeinmanytomany",
"Value": false
},
"CanBePrimaryEntityInRelationship": {
"CanBeChanged": false,
"ManagedPropertyLogicalName": "canbeprimaryentityinrelationship",
"Value": false
},
"CanBeRelatedEntityInRelationship": {
"CanBeChanged": false,
"ManagedPropertyLogicalName": "canberelatedentityinrelationship",
"Value": false
},
"CanChangeHierarchicalRelationship": {
"CanBeChanged": false,
"ManagedPropertyLogicalName": "canchangehierarchicalrelationship",
"Value": false
},
"CanChangeTrackingBeEnabled": {
"CanBeChanged": true,
"ManagedPropertyLogicalName": "canchangetrackingbeenabled",
"Value": true
},
"CanCreateAttributes": {
"CanBeChanged": false,
"ManagedPropertyLogicalName": "cancreateattributes",
"Value": false
},
"CanCreateCharts": {
"CanBeChanged": false,
"ManagedPropertyLogicalName": "cancreatecharts",
"Value": true
},
"CanCreateForms": {
"CanBeChanged": false,
"ManagedPropertyLogicalName": "cancreateforms",
"Value": false
},
"CanCreateViews": {
"CanBeChanged": false,
"ManagedPropertyLogicalName": "cancreateviews",
"Value": true
},
"CanEnableSyncToExternalSearchIndex": {
"CanBeChanged": false,
"ManagedPropertyLogicalName": "canenablesynctoexternalsearchindex",
"Value": false
},
"CanModifyAdditionalSettings": {
"CanBeChanged": true,
"ManagedPropertyLogicalName": "canmodifyadditionalsettings",
"Value": true
},
"CanTriggerWorkflow": false,
"ChangeTrackingEnabled": true,
"CollectionSchemaName": "ActivityPointers",
"DataProviderId": null,
"DataSourceId": null,
"DaysSinceRecordLastModified": 0,
"Description": {
"LocalizedLabels": [
{
"HasChanged": null,
"IsManaged": true,
"Label": "Task performed, or to be performed, by a user. An activity is any action for which an entry can be made on a calendar.",
"LanguageCode": 1033,
"MetadataId": "499709b3-2241-db11-898a-0007e9e17ebd"
}
],
"UserLocalizedLabel": {
"HasChanged": null,
"IsManaged": true,
"Label": "Task performed, or to be performed, by a user. An activity is any action for which an entry can be made on a calendar.",
"LanguageCode": 1033,
"MetadataId": "499709b3-2241-db11-898a-0007e9e17ebd"
}
},
"DisplayCollectionName": {
"LocalizedLabels": [
{
"HasChanged": null,
"IsManaged": true,
"Label": "Activities",
"LanguageCode": 1033,
"MetadataId": "4b9709b3-2241-db11-898a-0007e9e17ebd"
}
],
"UserLocalizedLabel": {
"HasChanged": null,
"IsManaged": true,
"Label": "Activities",
"LanguageCode": 1033,
"MetadataId": "4b9709b3-2241-db11-898a-0007e9e17ebd"
}
},
"DisplayName": {
"LocalizedLabels": [
{
"HasChanged": null,
"IsManaged": true,
"Label": "Activity",
"LanguageCode": 1033,
"MetadataId": "4a9709b3-2241-db11-898a-0007e9e17ebd"
}
],
"UserLocalizedLabel": {
"HasChanged": null,
"IsManaged": true,
"Label": "Activity",
"LanguageCode": 1033,
"MetadataId": "4a9709b3-2241-db11-898a-0007e9e17ebd"
}
},
"EnforceStateTransitions": false,
"EntityColor": "#505050",
"EntityHelpUrl": null,
"EntityHelpUrlEnabled": false,
"EntitySetName": "activitypointers",
"ExternalCollectionName": null,
"ExternalName": null,
"HasActivities": false,
"HasChanged": null,
"HasFeedback": false,
"HasNotes": false,
"IconLargeName": null,
"IconMediumName": null,
"IconSmallName": null,
"IconVectorName": null,
"IntroducedVersion": "5.0.0.0",
"IsAIRUpdated": false,
"IsActivity": false,
"IsActivityParty": false,
"IsAuditEnabled": {
"CanBeChanged": false,
"ManagedPropertyLogicalName": "canmodifyauditsettings",
"Value": false
},
"IsAvailableOffline": true,
"IsBPFEntity": false,
"IsBusinessProcessEnabled": false,
"IsChildEntity": false,
"IsConnectionsEnabled": {
"CanBeChanged": false,
"ManagedPropertyLogicalName": "canmodifyconnectionsettings",
"Value": true
},
"IsCustomEntity": false,
"IsCustomizable": {
"CanBeChanged": false,
"ManagedPropertyLogicalName": "iscustomizable",
"Value": true
},
"IsDocumentManagementEnabled": false,
"IsDocumentRecommendationsEnabled": false,
"IsDuplicateDetectionEnabled": {
"CanBeChanged": false,
"ManagedPropertyLogicalName": "canmodifyduplicatedetectionsettings",
"Value": false
},
"IsEnabledForCharts": true,
"IsEnabledForExternalChannels": false,
"IsEnabledForTrace": false,
"IsImportable": false,
"IsInteractionCentricEnabled": true,
"IsIntersect": false,
"IsKnowledgeManagementEnabled": false,
"IsLogicalEntity": false,
"IsMSTeamsIntegrationEnabled": false,
"IsMailMergeEnabled": {
"CanBeChanged": false,
"ManagedPropertyLogicalName": "canmodifymailmergesettings",
"Value": false
},
"IsManaged": true,
"IsMappable": {
"CanBeChanged": false,
"ManagedPropertyLogicalName": "ismappable",
"Value": false
},
"IsOfflineInMobileClient": {
"CanBeChanged": false,
"ManagedPropertyLogicalName": "canmodifymobileclientoffline",
"Value": false
},
"IsOneNoteIntegrationEnabled": false,
"IsOptimisticConcurrencyEnabled": true,
"IsPrivate": false,
"IsQuickCreateEnabled": false,
"IsReadOnlyInMobileClient": {
"CanBeChanged": false,
"ManagedPropertyLogicalName": "canmodifymobileclientreadonly",
"Value": false
},
"IsReadingPaneEnabled": true,
"IsRenameable": {
"CanBeChanged": false,
"ManagedPropertyLogicalName": "isrenameable",
"Value": true
},
"IsSLAEnabled": false,
"IsSolutionAware": false,
"IsStateModelAware": false,
"IsValidForAdvancedFind": true,
"IsValidForQueue": {
"CanBeChanged": false,
"ManagedPropertyLogicalName": "canmodifyqueuesettings",
"Value": false
},
"IsVisibleInMobile": {
"CanBeChanged": false,
"ManagedPropertyLogicalName": "canmodifymobilevisibility",
"Value": false
},
"IsVisibleInMobileClient": {
"CanBeChanged": false,
"ManagedPropertyLogicalName": "canmodifymobileclientvisibility",
"Value": true
},
"LogicalCollectionName": "activitypointers",
"LogicalName": "activitypointer",
"MetadataId": "c821cd41-f315-43d1-8fa6-82787b6f06e7",
"MobileOfflineFilters": "",
"ObjectTypeCode": 4200,
"OwnershipType": "UserOwned",
"PrimaryIdAttribute": "activityid",
"PrimaryImageAttribute": null,
"PrimaryNameAttribute": "subject",
"Privileges": [
{
"CanBeBasic": true,
"CanBeDeep": true,
"CanBeEntityReference": false,
"CanBeGlobal": true,
"CanBeLocal": true,
"CanBeParentEntityReference": false,
"Name": "prvCreateActivity",
"PrivilegeId": "091df793-fe5e-44d4-b4ca-7e3f580c4664",
"PrivilegeType": "Create"
},
{
"CanBeBasic": true,
"CanBeDeep": true,
"CanBeEntityReference": false,
"CanBeGlobal": true,
"CanBeLocal": true,
"CanBeParentEntityReference": false,
"Name": "prvReadActivity",
"PrivilegeId": "650c14fe-3521-45fe-a000-84138688e45d",
"PrivilegeType": "Read"
},
{
"CanBeBasic": true,
"CanBeDeep": true,
"CanBeEntityReference": false,
"CanBeGlobal": true,
"CanBeLocal": true,
"CanBeParentEntityReference": false,
"Name": "prvWriteActivity",
"PrivilegeId": "0dc8f72c-57d5-4b4d-8892-fe6aac0e4b81",
"PrivilegeType": "Write"
},
{
"CanBeBasic": true,
"CanBeDeep": true,
"CanBeEntityReference": false,
"CanBeGlobal": true,
"CanBeLocal": true,
"CanBeParentEntityReference": false,
"Name": "prvDeleteActivity",
"PrivilegeId": "bb4457f2-9b45-4482-a95a-7adef25f388a",
"PrivilegeType": "Delete"
},
{
"CanBeBasic": true,
"CanBeDeep": true,
"CanBeEntityReference": false,
"CanBeGlobal": true,
"CanBeLocal": true,
"CanBeParentEntityReference": false,
"Name": "prvAssignActivity",
"PrivilegeId": "8b99344e-ebbf-4f84-8438-e1e34d194de9",
"PrivilegeType": "Assign"
},
{
"CanBeBasic": true,
"CanBeDeep": true,
"CanBeEntityReference": false,
"CanBeGlobal": true,
"CanBeLocal": true,
"CanBeParentEntityReference": false,
"Name": "prvShareActivity",
"PrivilegeId": "b5f2ee06-d359-4495-bbda-312aae1c6b1e",
"PrivilegeType": "Share"
},
{
"CanBeBasic": true,
"CanBeDeep": true,
"CanBeEntityReference": false,
"CanBeGlobal": true,
"CanBeLocal": true,
"CanBeParentEntityReference": false,
"Name": "prvAppendActivity",
"PrivilegeId": "78777c10-09ab-4326-b4c8-cf5729702937",
"PrivilegeType": "Append"
},
{
"CanBeBasic": true,
"CanBeDeep": true,
"CanBeEntityReference": false,
"CanBeGlobal": true,
"CanBeLocal": true,
"CanBeParentEntityReference": false,
"Name": "prvAppendToActivity",
"PrivilegeId": "6ec8e901-d770-44c0-8f12-d07425f638bd",
"PrivilegeType": "AppendTo"
}
],
"RecurrenceBaseEntityLogicalName": null,
"ReportViewName": "FilteredActivityPointer",
"SchemaName": "ActivityPointer",
"SyncToExternalSearchIndex": false,
"UsesBusinessDataLabelTable": false
}
I reviewed this and I agree that there is no explicit entity metadata attribute akin to IsCreatable.
You could wrap an attempt to Create an empty entity of the type in a try / catch block.
When I ran:
var pointer = new ActivityPointer();
pointer.Create(svc);
The service threw this exception, even though the pointer entity contains no attributes:
System.ServiceModel.FaultException`1: 'The 'Create' method does not
support entities of type 'activitypointer'.'
This article lists the entities that support the IOrganizationService Create method under "Supported Entities".
Here is the list:
Account
ActivityMimeAttachment
Annotation
AnnualFiscalCalendar
Appointment
AsyncOperation
AttributeMap
BusinessUnit
BusinessUnitNewsArticle
Calendar
Campaign
CampaignActivity
CampaignResponse
ColumnMapping
Competitor
Connection
ConnectionRole
ConnectionRoleObjectTypeCode
ConstraintBasedGroup
Contact
Contract
ContractDetail
ContractTemplate
ConvertRule
ConvertRuleItem
CustomerAddress
CustomerOpportunityRole
CustomerRelationship
Discount
DiscountType
DuplicateRule
DuplicateRuleCondition
DynamicProperty
DynamicPropertyAssociation
DynamicPropertyInstance
DynamicPropertyOptionSetItem
Email
EmailServerProfile
Entitlement
EntitlementChannel
EntitlementTemplate
EntitlementTemplateChannel
Equipment
ExchangeSyncIdMapping
Fax
FieldPermission
FieldSecurityProfile
FixedMonthlyFiscalCalendar
Goal
GoalRollupQuery
HierarchyRule
HierarchySecurityConfiguration
Import
ImportEntityMapping
ImportFile
ImportJob
ImportMap
Incident
IncidentResolution
Invoice
InvoiceDetail
IsvConfig
KbArticle
KbArticleComment
KbArticleTemplate
Lead
Letter
List
LookUpMapping
Mailbox
MailMergeTemplate
Metric
MonthlyFiscalCalendar
msdyn_PostAlbum
msdyn_PostConfig
msdyn_PostRuleConfig
msdyn_wallsavedquery
msdyn_wallsavedqueryusersettings
Opportunity
OpportunityClose
OpportunityProduct
OrderClose
OrganizationUI
OwnerMapping
PhoneCall
PickListMapping
PluginAssembly
PluginType
Position
Post
PostComment
PostFollow
PostLike
PriceLevel
PrincipalObjectAttributeAccess
ProcessSession
ProcessTrigger
Product
ProductAssociation
ProductPriceLevel
ProductSubstitute
Publisher
PublisherAddress
QuarterlyFiscalCalendar
Queue
QueueItem
Quote
QuoteClose
QuoteDetail
RecurrenceRule
RecurringAppointmentMaster
RelationshipRole
RelationshipRoleMap
Report
ReportCategory
ReportEntity
ReportVisibility
ResourceSpec
Role
RollupField
RoutingRule
RoutingRuleItem
SalesLiterature
SalesLiteratureItem
SalesOrder
SalesOrderDetail
SavedQuery
SavedQueryVisualization
SdkMessageProcessingStep
SdkMessageProcessingStepImage
SdkMessageProcessingStepSecureConfig
SemiAnnualFiscalCalendar
Service
ServiceAppointment
ServiceEndpoint
SharePointDocument
SharePointDocumentLocation
SharePointSite
Site
SLA
SLAItem
SLAKPIInstance
SocialActivity
SocialInsightsConfiguration
SocialProfile
Solution
Subject
SystemForm
SystemUser
Task
Team
TeamTemplate
Template
Territory
TraceLog
TransactionCurrency
TransformationMapping
TransformationParameterMapping
UoM
UoMSchedule
UserEntityInstanceData
UserEntityUISettings
UserForm
UserQuery
UserQueryVisualization
WebResource
Workflow
WorkflowDependency
WorkflowLog

Amchart not initialized with data

Am Chart showing incorrectly, Here is following ajax code, incorrect thumb of chart.
I am using ajax to get the response and initialized the amchart (area)
Ajax json response data
{"success":true,"graph_data":[{"date":"2018-06-21","value":121.65},{"date":"2018-06-20","value":121.65},{"date":"2018-06-19","value":121.5},{"date":"2018-06-18","value":121.3},{"date":"2018-06-17","value":120.55},{"date":"2018-06-16","value":119.84},{"date":"2018-06-14","value":119.88}],"min_period":"DD","message":null}
Here code which I am initializing for amchart
var chart = AmCharts.makeChart( "graph_chart_div", {
"type": "serial",
"theme": "light",
"marginRight": 5,
"marginLeft": 5,
"minPeriod":response.min_period,
"autoMarginOffset": 5,
"dataDateFormat": "YYYY-MM-DD",
"valueAxes": [ {
"id": "v1",
"axisAlpha": 0,
"position": "left",
"ignoreAxisWidth": true
} ],
"balloon": {
"borderThickness": 1,
"shadowAlpha": 0
},
"graphs": [ {
"id": "g1",
"balloon": {
"drop": true,
"adjustBorderColor": false,
"color": "#ffffff",
"type": "smoothedLine"
},
"fillAlphas": 0.2,
"bullet": "round",
"bulletBorderAlpha": 1,
"bulletColor": "#FFFFFF",
"bulletSize": 5,
"hideBulletsCount": 50,
"lineThickness": 2,
"title": "red line",
"useLineColorForBulletBorder": true,
"valueField": "value",
"balloonText": "<span style='font-size:18px;'>[[value]]</span>"
} ],
"chartCursor": {
"valueLineEnabled": true,
"valueLineBalloonEnabled": true,
"cursorAlpha": 0,
"zoomable": false,
"valueZoomable": true,
"valueLineAlpha": 0.5
},
"valueScrollbar": {
"autoGridCount": true,
"color": "#000000",
"scrollbarHeight": 50
},
"categoryField": "date",
"categoryAxis": {
"gridPosition": "start",
"labelRotation": 45,
"minorGridEnabled": true,
/* ENSURE 2 LINES BELOW ARE ADDED */
"autoGridCount": false,
"gridCount": 12,
"parseDates": true,
"dashLength": 1,
// "minorGridEnabled": true
},
"export": {
"enabled": false
},
// "dataProvider": graph_data
"dataProvider": response.graph_data
} );
This is currently initialized chart
I want to show the following chart for my data
Your date data is out of order. AmCharts requires your date-based data to be in date-ascending order when using parseDates.
Important: If this is set to true, the data points needs to come pre-ordered in ascending order. Data with incorrect order might result in visual and functional glitches on the chart.
Once you fix the sort order, your chart will render correctly.

jqGrid is empty with JSON call

My jqGrid is coming empty with JSON call. Though it is working with datatype='jsonstring' but not with json type. here is my JSON
{
"d": {
"total": 6,
"page": 1,
"records": 6,
"rows": [
{
"id": 1,
"Name": "James",
"EMPID": "0000000056",
"EMPDATE": "",
"JOBTYPE": "REQ",
"DEPTID": "FIN",
"STATUS": "P1"
},
{
"id": 2,
"Name": "James",
"EMPID": "R2",
"EMPDATE": "",
"JOBTYPE": "REQ",
"DEPTID": "FIN",
"STATUS": "P1"
},
{
"id": 3,
"Name": "James",
"EMPID": "V2",
"EMPDATE": "",
"JOBTYPE": "VOU",
"DEPTID": "FIN",
"STATUS": ""
},
{
"id": 4,
"Name": "James",
"EMPID": "V1",
"EMPDATE": "",
"JOBTYPE": "VOU",
"DEPTID": "FIN",
"STATUS": ""
},
{
"id": 5,
"Name": "James",
"EMPID": "009017",
"EMPDATE": "",
"JOBTYPE": "PY",
"DEPTID": "",
"STATUS": "V2"
},
{
"id": 6,
"Name": "James",
"EMPID": "009018",
"EMPDATE": "",
"JOBTYPE": "PY",
"DEPTID": "",
"STATUS": "V1"
}
]
}
}
and my jqGrid call from javascript is
function getgrid()
{
$("#list").jqGrid({
url:'http://10.240.26.41/GetGridFields',
datatype: 'json',
mtype: 'GET',
ajaxGridOptions: { contentType: 'application/json; charset=utf-8' },
//serializeGridData: function (postData) {
// return JSON.stringify(postData);
// },
jsonReader: { repeatitems: false, root: "d.rows", page: "d.page", total: "d.total", records: "d.records" },
colModel: [
{ name: 'id', key: true, width: 60, align: "center", hidden: false },
{ name: 'Name', width: 80, sortable: false, hidden: false },
{ name: 'EMPID', width: 180, sortable: false, hidden: false },
{ name: 'EMPDATE', width: 180, sortable: false, hidden: false },
{ name: 'JOBTYPE', width: 180, sortable: false, hidden: false },
{ name: 'DEPTID', width: 180, sortable: false, hidden: false },
{ name: 'STATUS', width: 180, sortable: false, hidden: false }
],
rowNum: 10,
rowList: [10, 20, 300],
pager: "#pager",
viewrecords: true,
gridview: true,
rownumbers: true,
height: 230,
caption: 'Emp Detail'
})
}
Please let me know where i am wrong here. It is working fine with jsonstring.
How you can see on the demo your jqGrid can read your JSON data. I made in the demo only minimal optimization changes which don't important for your main problem.
So I suppose, that you have either the problem with the usage of full URL (you should use '/GetGridFields' instead of 'http://10.240.26.41/GetGridFields') because you can't get Ajax call to another IP host because of the same origin policy. One other possible reason is that you have wrong 'Content-Type' or some other HTTP header. You can examine the HTTP headers with respect of Fiddler, Firebug or just with Developer Tools of IE or Chrome (see "Network" tab).
In any way I would recommend you to include loadError handler to jqGrid. See the answer for details.
I suggest you validate your json result using jslint since using jsonstring is working could be a format type problem

Resources